yline() or xline() are typically used to add reference values:
. scatter yvar xvar, yline(10)
. scatter yvar year, xline(1944 1989)
To give the line in the first example the same look as used to draw an axis, we could specify
. scatter yvar xvar, yline(10, lstyle(foreground))
If we wanted to give the lines used in the second example the same look as used to draw grids,
we could specify
. scatter yvar year, xline(1944 1989, lstyle(grid))
added line options — Options for adding lines to twoway graphs 3
Interpretation of repeated options
Options yline() and xline() may be repeated, and each is executed separately. Thus different
styles can be used for different lines on the same graph:
. scatter yvar year, xline(1944) xline(1989, lwidth(3))
Reference
Cox, N. J. 2009. Stata tip 82: Grounds for grids on graphs. Stata Journal 9: 648–651.
来源:
http://www.stata.com/manuals13/g-3added_line_options.pdf
Suppose that we wanted to place vertical lines for the previously mentioned holidays. We could
specify the dates in the tline() option as follows:
tsline calories, tline(28nov2002 25dec2002)
来源:
http://www.stata.com/manuals13/tstsline.pdf#tstsline