** it finds and reads the color style file for each named color ** this code snippet taken from full_palette.ado with modifications Gen inten=real(intenS) // this is the actual numeric value of intensity ** uses the string variables as value labels for the numerical variables Replace col_int_num= ii' if case=ii' local ii=`ii'+1 } } Replace intenS=word("`intenlist'",`inten') if case=`ii' Replace basecolor=word("`colorlist'",`color') if case=`ii' ** fill in the strings with colors and intensities ** This code generates the data for the plotsĭisp "ncolor `ncolor' ninten `ninten' ncases `ncases'" Local yrange "`lowint' (`edgegap') `maxint'" ** This code to get a decent intensity range in the graph regardless of entries Local intnumlist=subinstr("`intenlist'"," ",", ".) // a numlist with commas Local colorlist "ebblue eltblue orange orange_red red uwred purple" * uwred is a color I created and saved in my personal ado file * edits code so colors now print in the order of colorlist * uses syntax "scatter y1 y2 x" to print two-line labels * calculates and prints RGB values as well as color names style file for named color and identifies RGB code * Stata program to generate color swatches I also tested creating my own color (uwred) and saving it in a. But I wanted to see ranges of colors using the intensity values across several different named colors. The ado file full_palette generates a swatch of the 66 named colors in Stata, with their RGB values (you can access this by typing help full_palette and installing the ado), and the built-in ado palette color will show color samples and the RGB values for two colors (type help palette color to see the syntax of the command). Numbers less than 1 lighten the color and numbers greater than 1 darken the color. Named colors can be modified with the syntax “color*#. Color Swatch GeneratorĪlthough Stata can generate colors using any set of RGB values, for a variety of reasons* I found it easiest to work with the built-in named colors. Pro tip: remember to reset the plot macro to ” ” (empty) (or use a new macro name each time) or you will get unpleasant results with repeated graphs. In this code, each line gets added to the macro plotlist. Local plotlist "`plotlist' (code_for_one_line )" Trick 2 is to use Stata macros to generate the lines of a plot. Or self-labeling scatterplots by having a label for all values. Trick 1 that I have learned is to generate self-labeling lines by creating a variable that has the label only in the last value of the x-axis variable, year in my case. UPDATED to include RGB values in the color palette and to give the formulas for calculating them from intensities. Everybody else may wish to give it a pass. This is a “stats nerd” post that assumes the reader uses Stata, a statistical package. A few readers may be interested in how I used Stata to create the color scheme for the offenses in the graphs I’ve posted recently.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |