Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: xtline and addplot option

From   Nick Cox <>
Subject   Re: st: xtline and addplot option
Date   Wed, 29 Jun 2011 08:24:17 +0100

I'd try doing this

keep if newids < 6
xtline xvar, t(year) i(city_state) addplot(line xvar2 year)


On Tue, Jun 28, 2011 at 8:18 PM, Lindsay Pettingill <> wrote:

> I'd like to add an additional plot to a series of time-series graphs.
> I can do this with 'addplot', but I have so many units that I'd like
> to break the graph output into about 10 units at a time. In short, I'd
> like to use an "if" statement to subset the data and draw graphs and
> plots for these subsets (otherwise there are just way too many plots
> to look at on the graph output)
> here is what I have:
> xtline xvar if newid<6, t(year) i(city_state)
> This gives me the initial graphs I want, for the first 6 cities in my
> dataset. I want to then add the additional plots via addplot:
> xtline xvar if newids<6, t(year) i(city_state) addplot(line xvar2 year
> if newids<6)
> This gives me the graphs and addplots that I want, for the first six
> cities- but it also produces (empty) plots for all additional
> cities... but it seems that I cannot specify an "if" option after the
> parens to limit the plotted graphs to the first 6 cities.
> (ie this does not work: xtline xvar, t(year) i(city_state)
> addplot(line xvar2 year) if newids<6
> Is there a way to exclude those cities that I do not want on the graph
> output, short of subsetting the dataset into separate files and then
> plotting the graphs for each?
*   For searches and help try:

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