Bookmark and Share

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


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

Re: st: (Many) overlaid graphs


From   Joerg Luedicke <[email protected]>
To   [email protected]
Subject   Re: st: (Many) overlaid graphs
Date   Thu, 19 May 2011 18:06:20 -0400

On Thu, May 19, 2011 at 5:11 PM, Maria Ana Vitorino
<[email protected]> wrote:
> Dear Statalist users,
>
> I'm trying to do multiple overlaid graphs but I'm not sure how to do it
> since I have a very large number of time series.
> The data is the following:
>
>
>     +------------------------+
>     | Person   Weight   Date |
>     |------------------------|
>  1. |  Name1       50      1 |
>  2. |  Name1       55      2 |
>  3. |  Name1       50      3 |
>  4. |  Name1       45      4 |
>  5. |    ...        .      . |
>     |------------------------|
>  6. |  Name2       85      2 |
>  7. |  Name2       88      4 |
>  8. |  Name3       68      1 |
>  9. |    ...        .      . |
>  10. |     ..        .      . |
>     |------------------------|
>  11. |  NameN        .      . |
>     +------------------------+
>
> If I just wanted to do the plot for the first two people, I could use
> something like:
>
> twoway (scatter weight date if Person=="Name1", connect(l) sort xlab(,
> valuelabel)  legend(label(1 "Name1"))) (scatter weight date if
> Person=="Name2", connect(l) sort xlab(, valuelabel)  legend(label(2
> "Name2")))
>
>
> But, what I am trying to achieve is a plot with lines for ALL the people in
> the dataset. Since there are many people it is cumbersome to add one plot
> per person manually.
>
> Is there an easier way of doing the plot with all the series in the same
> graph (and with a legend saying which series refers to each person)?
>
> Thanks for the help!

One straightforward way of doing that would be:

xtline Weight , overlay  i(Person) t(Date)

You do not need the  i and t specification if you xtset your data
(-help xtset-, but in which case your id variable would not be allowed
to be a string variable).

J.

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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