8/11/2023 0 Comments Xline stata color![]() 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. dotplot uses only one colour in the body of the graph. As we supply two pairs of coordinates the result is a single straight line (which happens to be horizontal). Quick start Add a horizontal line at the value 0 graphcommand : : :,: : : yline(0) Add horizontal lines at the values of 9, 11, and 17 graphcommand : : :,: : : yline(9 11 17) Add a vertical line at the value of 17.2 graphcommand : : :,: : : xline(17. Similarly, stripplot and dotplot allow the use of xline() and yline(). 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. 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. So, to subvert that you have to supply your line as data. 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). 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. 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. grstyle set color black.08: plotregion plotregionline //set. Time periods are shaded if the indicator variable equals 1, and not shaded if it's missing. xline(0) HOW TO MAKE STATA GRAPHS LOOK NICE (OR A LITTLE BIT LIKE RâS GGPLOT2 GRAPHS) ssc install grstyle, replace ssc install palettes, replace 5) set scheme s2color // sets Stata design scheme to default s2color grstyle init // initiates grstyle grstyle set horizontal. graph y1 y2 yn x in if, by(var) xline(xint) yline(yint).![]() I'm graphing a time series and shading certain time periods based on a Boolean indicator variable in Stata 13.1 on Windows 7. Disclaimer: we are not affiliated with Stata. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |