Transcription of Title stata.com xtline — Panel-data line plots
1 Panel-data line plotsSyntaxMenuDescriptionOptions for graph by panelOptions for overlaid panelsRemarks and examplesAlso seeSyntaxGraph by panelxtlinevarlist[if][in][,paneloptions ]Overlaid panelsxtlinevarname[if][in], overlay[overlaidoptions]paneloptionsDesc riptionMaini(varnamei)usevarnameias the panelIDvariablet(varnamet)usevarnametas the time variablePlotclineoptionsaffect rendition of the plotted points connected by linesAdd plotsaddplot(plot)add other plots to the generated graphY axis, Time axis, Titles, Legend, Overalltwowayoptionsany options other thanby()documented in [G-3]twowayoptionsbyopts(byopts)affect appearance of the combined graphoverlaidoptionsDescriptionMainoverl ayoverlay each panel on the same graphi(varnamei)usevarnameias the panelIDvariablet(varnamet)usevarnametas the time variablePlotsplot#opts(clineoptions)affe ct rendition of the#panel lineAdd plotsaddplot(plot)add other plots to the generated graphY axis, Time axis, Titles, Legend, Overalltwowayoptionsany options other thanby()documented in [G-3]twowayoptionsA panel variable and a time variable must be specified.
2 Usextset(see [XT]xtset) or specify thei()andt()options. Thet()option allows noninteger values for the time variable, whereasxtsetdoes xtline Panel-data line plotsMenuStatistics>Longitudinal/panel data>Line plotsDescriptionxtlinedraws line plots for panel for graph by panel Main i(varnamei)andt(varnamet)override the panel settings fromxtset; see [XT] to be a string take on noninteger values and have repeated valueswithin panel. That is to say, it can be any numeric variable that you would like to specify for thex-dimension of the graph. It is an error to specifyi()withoutt()and vice versa. Plot clineoptionsaffect the rendition of the plotted points connected by lines; see [G-3]clineoptions. Add plots addplot(plot)provides a way to add other plots to the generated graph; see [G-3]addplotoption. Y axis, Time axis, Titles, Legend, Overall twowayoptionsare any of the options documented in [G-3]twowayoptions, excludingby().
3 Theseinclude options for titling the graph (see [G-3]titleoptions) and for saving the graph to disk (see[G-3]savingoption).byopts(byopts)all ows all the options documented in [G-3]byoption. These options affect theappearance of the ()may not be combined for overlaid panels Main overlaycauses the plot from each panel to be overlaid on the same graph. The default is to generateplots by panel. This option may not be combined withbyopts()or be specified when there aremultiple variables (varnamei)andt(varnamet)override the panel settings fromxtset; see [XT] to be a string take on noninteger values and have repeated valueswithin panel. That is to say, it can be any numeric variable that you would like to specify for thex-dimension of the graph. It is an error to specifyi()withoutt()and vice versa. plots plot#opts(clineoptions)affect the rendition of the#th panel (in sorted order).
4 Theclineoptionscan affect whether and how the points are connected; see [G-3]clineoptions. Add plots addplot(plot)provides a way to add other plots to the generated graph; see [G-3] Panel-data line plots 3 Y axis, Time axis, Titles, Legend, Overall twowayoptionsare any of the options documented in [G-3]twowayoptions, excludingby(). Theseinclude options for titling the graph (see [G-3]titleoptions) and for saving the graph to disk (see[G-3]savingoption).Remarks and 1 Suppose that Tess, Sam, and Arnold kept a calorie log for an entire calendar year. At the end ofthe year, if they pooled their data together, they would have a dataset (for example, )that contains the number of calories each of them consumed for 365 days. They could then usextsetto identify the date variable and treat each person as a panel and usextlineto plot the caloriesversus time for each person use xtset person daypanel variable: person (strongly balanced)time variable: day, 01jan2002 to 31dec2002delta: 1 day.
5 xtline calories, tlabel(#3)350040004500500035004000450050 0001jan200201jul200201jan200301jan200201 jul200201jan2003 TessSamArnoldCalories consumedDateGraphs by personSpecify theoverlayoption so that the values are plotted on the same graph to provide a bettercomparison among Tess, Sam, and xtline Panel-data line plots . xtline calories, overlay3500400045005000 Calories consumed01jan200201apr200201jul200201oct 200201jan2003 DateTessSamArnoldAlso see[XT]xtset Declare data to be panel data[G-2]graph twoway Twoway graphs[TS]tsline Plot time-series data