![]() 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. (If so, please report back here!) And then, you should have what you need for your actual application.Īdded in edit - the author's original Stata Journal article is available for free download at and perhaps among the extensive writeup there will be found some relevant examples.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. If not, perhaps you can alter the second two examples to produce success. Perhaps the first two examples suffice for you. Or, possibly, the options need to be placed differently, although I admit the section of the help titled "Placement of options" did not reveal to me the problem with my naive code.īut for me this would all now be trial and error. For g3 and g4, though, the graph combine that is obviously used to produce the array of plots does not seem to notice the options. The results were as I hoped for g1 and g2. Regress price mpg headroom trunk length turn if foreign=1Ĭoefplot domestic foreign, drop(_cons) xline(0) graphregion(color(white)) bgcolor(white) name(g2)Ĭoefplot domestic || foreign, drop(_cons) xline(0) graphregion(color(white)) bgcolor(white) name(g3)Ĭoefplot domestic || foreign, yline(0) bycoefs vertical byopts(yrescale) graphregion(color(white)) bgcolor(white) name(g4)Copy this into your do-file editor and run it. Regress price mpg headroom trunk length turn if foreign=0 Regress price mpg headroom trunk length turnĬoefplot, drop(_cons) xline(0) graphregion(color(white)) bgcolor(white) name(g1)
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |