Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Arbitrary limits on number of data series for line plots


From   "Allan Reese (Cefas)" <allan.reese@cefas.co.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Arbitrary limits on number of data series for line plots
Date   Thu, 27 Apr 2006 11:13:01 +0100

Hi Stata plotters
I have data in which numerous individuals were each observed for a short time.  It makes sense to plot each individual against time, so the data have been restructured with observations for each date and a response variable for each individual:

  day      y1   y2   y3 ...
   1        v    .    .
   2        v    .    .
   3        v    v    v
   4        v    v    v
   5        v    .    v
   6        v    .    v
   7        .    .    v

(v where there was an observation, and the days extend over several years.)

>From such data it is easy to plot several lines on one plot:
scatter  y1-y3 day, c(l l l l) ms(i i i i)

The extra items in the connect and symbol lists are ignored, which is fortunate as I might use "y1-y20" where some individuals have been dropped so the actual number of variables is not obvious.

The first limit was hit at 20 y series.  I can't find in the documentation a limit for the varlist in a scatter command.  I recall it used to be about 29 y variables.  The command
scatter  y1-y25 day, legend(off) pcycle(1)
appears to work.  The options are only to avoid a multicolored plot squashed by a huge legend.
More points appear on each plot of y1-y15, y1-y20, y1-y25 so it appears all series are plotted.

However
scatter y1-y21 day, c(l l l l l l l l l l l l l l l l l l l l l )
                    ms(i i i i i i i i i i i i i i i i i i i i i ) legend(off) pcycle(1)
does NOT work.  Having more than 20 items in the option lists appears to crash some buffer, and the plot reverts to default markers.

BUG?  It appears the varlist can have more than 20 y variables, but the connect list can have only 20 items.  (The style list recycles after 15 but I haven't tried extending that.)

Since I had more than 20 individuals, the next step was to overlay scatterplots:
scatter y1-y20 datevar, c(L L L L L   L L L L L   L L L L L   L L L L L   )
      ms(i i i i i  i i i i i  i i i i i  i i i i i  )
      || scatter y21-y40 datevar, c(L L L L L   L L L L L   L L L L L   L L L L L   )
      ms(i i i i i  i i i i i  i i i i i  i i i i i  )
      || scatter y41-y60 datevar, c(L L L L L   L L L L L   L L L L L   L L L L L   )
      ms(i i i i i  i i i i i  i i i i i  i i i i i  )
      || scatter y61-y80 datevar, c(L L L L L   L L L L L   L L L L L   L L L L L   )
      ms(i i i i i  i i i i i  i i i i i  i i i i i  )
      || scatter y81-y100 datevar, c(L L L L L   L L L L L   L L L L L   L L L L L   )
      ms(i i i i i  i i i i i  i i i i i  i i i i i  )  pcycle(1) legend(off) xlab(,angle(20)) ylab(,angle(0))

And that (copied from the log) works.  But add one more "|| scatter y101 datevar" and get the error message "Too many variables specified".  100 variables may have seemed a generous limit when programmed, but can anyone suggest a method to draw more lines on the same graph?

Allan




***********************************************************************************
This email and any attachments are intended for the named recipient only.  Its unauthorised use, distribution, disclosure, storage or copying is not permitted.  If you have received it in error, please destroy all copies and notify the sender.  In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent.  All emails may be subject to monitoring.
***********************************************************************************


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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