


Thanks to Derek Wagner of Stata for his reply to our query on the maximum number of keys using label(). Legend(order(2 "Fitted regression line") ring(0) pos(5))īoth commands above will give the same graph. Legend(label(2 "Fitted regression line") order(2) ring(0) pos(5)) Thanks to Derek Wagner of Stata for his reply to our query on the maximum number of keys using label() and for pointing out the capabilities of order(). The legend key for the first- tw- plot, which by default is the y-variable name or label (if exists), is not displayed.Īnother advantage of using order() over label() is that label(), by default, is limited to hold 15 keys. Legend( order(2 "Fitted regression line") ring(0) pos(5))īoth commands above will result in the same graph (see below). Legend( label(2 "Fitted regression line") order(2) ring(0) pos(5)) Tw (scatter marriage divorce, mlabel(state2)) To illustrate, we use census.dta which is installed with Stata. But recently I learned that it also makes the label() suboption redundant. Author Mitch Abdon Posted on 17 February 2011 4 December 2020 Categories Graphics Tags function, graph, marker symbols, twoway 3 Comments on Functions and marker symbols The order() suboption makes label() redundantīefore, I thought that the order() suboption for graphic legend() option is only used to specify which legend keys will be shown and in which order you want them to be displayed. If this were not specified, as in the plot for y = x^2, the plot will be connected by 300 (the default) markers - ugly. What is "n(#)" for? This tells Stata to draw the plot at 20 points. In our case, we specified that the new plot type is a connected graph, for which you can specify marker symbols. The recast option will tell Stata to treat the plot as a new plot. Tw function y = x^2, range(-2 2) recast(connected) msymbol(O) || ///įunction y = x^3, range(-2 2) recast(connected) msymbol(T) n(20) || ///įunction y = x^4, range(-2 2) recast(connected) msymbol(S) n(20) /// For example:įunction y = x^3, range(-2 2) lpattern(-) || ///įunction y = x^4, range(-2 2) lpattern(.-) ///Ĭols(3) pos(5) ring(0) region(lcolor(none)))īut suppose you prefer to use marker symbols rather than line patterns to differentiate the line plots, how can you specify this option? Use the recast option (-help advanced_options-): These options are particularly helpful when you have many functions to plot. Tw function y = 4*x^2, range(-2 2) lcolor(red) lwidth(medthick) lpattern(-) For example, if you want to change the color, width, and pattern of the line use lcolor, lwidth, and lpattern options: It is easy to change the line attributes of the plot. If you want to draw the other side of the parabola or change the range, you can specify the range as follows: The default is that the function is drawn over the range. For example, the half of a parabola with the equation y = x^2 can be drawn by typing: Stata's -graph twoway function- draws the line plot of a specified function.
