![]() The legend keys are reordered to show “Domestic” first because option plegend(order(2 1)) is specified. The colorvar options allow you to customize the number of. ![]() You can color-code a wide variety of twoway plots, including scatterplots, bar graphs, dot plots, dropped-line plots, connected plots, spike plots, and several range and paired-coordinate plots. The plegend keys are labeled using the value label of variable foreign because option zlabel(,valuelabel) is specified. Now you can easily create these graphs with the colorvar options introduced in Stata 18. The legend is a plegend (the type of legend used for contour-line plots) instead of a clegend because option coloruseplegend is specified. The markers are colored using the colors of p1 and p2, the first and second colors used by the graph scheme, because option colorrule(phue) is specified. Because the colordiscrete option is used, the colors correspond to the two levels of foreign, 0 and 1. The color of the markers is determined by the value of the variable, foreign. twoway scatter mpg price, colorvar(foreign) colordiscreteĬolorrule(phue) zlabel(, valuelabel) coloruseplegend To draw a scatterplot of the variables mpg and price, type The combination of options coloruseplegend and colordiscrete is useful to display categorical variables. ![]() In the three examples above, the legend is a clegend (the type of legend used for contour plots) that corresponds to a z axis this legend is suited for numerical variables. Note that, for colordiscrete, the level is a point instead of an interval. ![]() (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.The color of the markers is determined by the value of the variable, weight2. Stata 15, colors may be complemented by opacity specified as. If not, perhaps you can alter the second two examples to produce success. two (scatter price weight) (lpoly price weight), xline(4000) +-+ -+. 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 Scheme files contain statements that define the default shape, color, and size of the various elements that compose a graph. 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 |