![]() You want a line which corresponds with 0 on the second y axis: (scatteri 0 `t1' 0 `t2', recast(line) yaxis(2))įor similar problems, one should be able to calculate the appropriate coordinates from the data in each case or fall back on a constant variable plotted as a horizontal line graph.ĮDIT: Revised version benefits from comments by Roberto Ferrer. As we supply two pairs of coordinates the result is a single straight line (which happens to be horizontal). Now the key is to fire up twoway scatteri but to recast the two points (in this case) to a line. In other examples, this may be dispensable. twoway (line glergdpc year if cnameSweden, lcolor(blue)), xline(1992 2009). The technique below is more general in not assuming that the added line need be horizontal.įirst for convenience, we calculate the endpoints of the line and put them in local macros. One way to do that is just to define a variable which is constant and plot it as a line graph. Suppose you store Long and Freese's SPost module in the e:\ado\plus directory of a memory. The crux of the matter is that Stata deals with dates as integers that have a special label attached to them by the format command (but not a value label). If you need to change the default path, run the. estout assembles a regression table from one or more models previously fitted and stored. So, to subvert that you have to supply your line as data. Command legend is unrecognized stata Basic syntax and usage. In essence, the idea behind yline() and similar options is to supply reference lines, which are never to be plotted on top of the data. Is it possible to force Stata to place this horizontal line on top of all other plots in the graph? The horizontal line is obscured by the shading because the shading is created first, but I need the shading to be created first because otherwise, it obscures the plot of the time series (since Stata doesn't support transparency/alpha blending). 2009.Stata tip 82: Grounds for grids on graphs. scatter yvar year, xline(1944) xline(1989, lwidth(3)) Reference Cox, N. Thus different styles can be used for different lines on the same graph. In practice, the indicator variable could be anything, which is why I don't want to hard code the values to shade in the twoway command, as seen in this Statalist post or the nber plugin in the SSC. Options yline() and xline() may be repeated, and each is executed separately. Ly_dev is the time series, and USRECQ is the indicator variable. Ytitle("Deviation from trend", axis(2))), Here is an example, using the freduse plugin ( ssc install freduse, replace): freduse GDPC1 USRECQ, clear I want to draw a horizontal line at the point on the y-axis where the time series equals 0. Time periods are shaded if the indicator variable equals 1, and not shaded if it's missing. pcarrowi- stays inside the inner plot region and does not reach the margins of the outer plot region, unless that margin is set to zero. ![]() The -xline- option draws a line from the x-axis to the top outer margin of the plot region. I'm graphing a time series and shading certain time periods based on a Boolean indicator variable in Stata 13.1 on Windows 7. By default, graphs have a margin between the inner and outer area of the plot region.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |