Stata 15 help for xtline

[XT] xtline -- Panel-data line plots

Syntax

Graph by panel

xtline varlist [if] [in] [, panel_options]

Overlaid panels

xtline varname [if] [in], overlay [overlaid_options]

panel_options Description ------------------------------------------------------------------------- Main i(varname_i) use varname_i as the panel ID variable t(varname_t) use varname_t as the time variable

Plot cline_options affect rendition of the plotted points connected by lines

Add plots addplot(plot) add other plots to the generated graph

Y axis, Time axis, Titles, Legend, Overall twoway_options any options other than by() documented in [G-3] twoway_options byopts(byopts) affect appearance of the combined graph -------------------------------------------------------------------------

overlaid_options Description ------------------------------------------------------------------------- Main overlay overlay each panel on the same graph i(varname_i) use varname_i as the panel ID variable t(varname_t) use varname_t as the time variable

Plots plot#opts(cline_options) affect rendition of the # panel line

Add plots addplot(plot) add other plots to the generated graph

Y axis, Time axis, Titles, Legend, Overall twoway_options any options other than by() documented in [G-3] twoway_options -------------------------------------------------------------------------

A panel variable and a time variable must be specified. Use xtset (see [XT] xtset) or specify the i() and t() options. The t() option allows noninteger values for the time variable, whereas xtset does not.

Menu

Statistics > Longitudinal/panel data > Line plots

Description

xtline draws line plots for panel data.

Options for graph by panel

+------+ ----+ Main +-------------------------------------------------------------

i(varname_i) and t(varname_t) override the panel settings from xtset. varname_i is allowed to be a string variable. varname_t can take on noninteger values and have repeated values within panel. That is to say, it can be any numeric variable that you would like to specify for the x-dimension of the graph. It is an error to specify i() without t() and vice versa.

+------+ ----+ Plot +-------------------------------------------------------------

cline_options affect the rendition of the plotted points connected by lines; see [G-3] cline_options.

+-----------+ ----+ Add plots +--------------------------------------------------------

addplot(plot) provides a way to add other plots to the generated graph; see [G-3] addplot_option.

+--------------------------------------------+ ----+ Y axis, Time axis, Titles, Legend, Overall +-----------------------

twoway_options are any of the options documented in help [G-3] twoway_options, excluding by(). These include options for titling the graph (see [G-3] title_options) and for saving the graph to disk (see [G-3] saving_option).

byopts(byopts) allows all the options documented in [G-3] by_option. These options affect the appearance of the by-graph. byopts() may not be combined with overlay.

Options for overlaid panels

+------+ ----+ Main +-------------------------------------------------------------

overlay causes the plot from each panel to be overlaid on the same graph. The default is to generate plots by panel. This option may not be combined with byopts() or be specified when there are multiple variables in varlist.

i(varname_i) and t(varname_t) override the panel settings from xtset. varname_i is allowed to be a string variable. varname_t can take on noninteger values and have repeated values within panel. That is to say, it can be any numeric variable that you would like to specify for the x-dimension of the graph. It is an error to specify i() without t() and vice versa.

+-------+ ----+ Plots +------------------------------------------------------------

plot#opts(cline_options) affect the rendition of the #th panel (in sorted order). The cline_options can affect whether and how the points are connected; see [G-3] cline_options.

+-----------+ ----+ Add plots +--------------------------------------------------------

addplot(plot) provides a way to add other plots to the generated graph; see [G-3] addplot_option.

+--------------------------------------------+ ----+ Y axis, Time axis, Titles, Legend, Overall +-----------------------

twoway_options are any of the options documented in [G-3] twoway_options, excluding by(). These include options for titling the graph (see [G-3] title_options) and for saving the graph to disk (see [G-3] saving_option).

Examples

Suppose that Tess, Sam, and Arnold kept a calorie log for an entire calendar year. At the end of the year, if they pooled their data together, they would have a dataset (for example, xtline1.dta) that contains the amount of calories consumed for 365 days for each of them. They could then use xtset to identify the date variable and treat each person as a panel, and then use xtline to plot the calories versus time for each person separately.

. sysuse xtline1 . xtset person day . xtline calories, tlabel(#3) (click to run)

Specify the overlay option so that the values are plotted on the same graph; this will provide a better comparison between Tess, Sam, and Arnold.

. xtline calories, overlay (click to run)


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index