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: Horizontal time line graph of individual with time events
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Horizontal time line graph of individual with time events
Date
Fri, 4 Mar 2011 11:29:57 +0000
Even the more complicated graph you cite looks doable quite nicely in Stata.
For that and your own problem the way ahead is to break it down into
separate tasks for -twoway-. For example, the little boxes on the
cited graph would just be -ms(Sh)- shown big enough to contain the
other symbols. That is the trick behind the first -stripplot- example
given at
http://www.survey-design.com.au/Usergraphs.html
Some technique is discussed at
SJ-8-2 gr0034 . . . . . . . . . . Speaking Stata: Between tables and graphs
(help labmask, seqvar if installed) . . . . . . . . . . . . N. J. Cox
Q2/08 SJ 8(2):269--289
outlines techniques for producing table-like graphs
but for the most part it's probably easier to go straight at it as an
application of -twoway rspike || scatter || scatter || scatter-.
For your cited graph I would create a vertical axis variable that just
goes 1, 2, 3, and then put age and sex into value labels like "2 m" "5
m". The reader would not see the y values, just the value labels.
Remember that whenever one is thinking table style (i.e. lowest row
number goes at the top) rather than graph style (i.e. lowest y value
goes at the bottom) -ysc(reverse)- does what you want.
Not every graph needs a different name, and if there isn't a name for
this that's a positive too.
As different graphs can have the same name, and vice versa,
terminology can just make trouble for everyone. I've seen the term
"line plot" which I thought was always just segmented lines used for a
scatter of point symbols along one line!
Here's some code to get you started on your graph.
twoway rspike sympstart lastfu id, horizontal || ///
scatter id admdate || ///
scatter id firstpcr || ///
scatter id lastpcr , ysc(reverse) yla(1/9, ang(h) noticks) ///
legend(order(2 "admdate" 3 "firstpcr" 4 "lastpcr") pos(3) col(1))
Simple tip, perhaps superfluous: Put graph commands this complicated
in the do-file editor giving yourself plenty of space and run from
there. Save recipes you want to repeat as self-contained do files that
would start by reading the data in.
Nick
On Fri, Mar 4, 2011 at 10:33 AM, Jannik Helweg-Larsen
<[email protected]> wrote:
> I'm searching for a way to illustrate horizontal timelines with
> markers for individual time events, preferably in line with this very
> nice graph- but been unable to identify the right kind of graph
>
> http://cid.oxfordjournals.org/content/52/suppl_1/S102/F1.expansion.html
>
> Although I realise that this kind of detailed graphical display is
> not routinely available- I would like to find som sort of graphing
> which comes close to this example:
>
> Is there a name for such a graph?
>
> To give a concrete example (real data):
>
> For each individual influenza patients hospitalized I would like to
> graph time (days) on horizontal lines starting from onset of symptoms
> illustrating the total time of hospitalisation, with indicators along
> these lines with:
>
> 1) Admission days after symptomstart
> 2) First day PCR positive for Influenza
> 3) Last Day PCR positive
> 4) Days after symptomstart starting tamiflu
> 5) Days after symptomstart stopping tamiflu
>
> id sympstart admdate firstpcr lastpcr tamistart
> tamistop lastfu
> 1. 10/12/2010 12/12/2010 22/12/2010 04/01/2011 22/12/2010
> 10/01/2011 21/01/2011
> 2. 18/12/2010 21/12/2010 31/12/2010 03/01/2011 02/01/2011
> 08/01/2011 10/01/2011
> 3. 01/01/2011 06/01/2011 06/01/2011 17/01/2011 07/01/2011
> 12/01/2011 27/01/2011
> 4. 03/01/2011 13/01/2011 13/01/2011 17/01/2011 14/01/2011
> 18/01/2011 25/01/2011
> 5. 04/01/2011 06/01/2011 16/01/2011 19/01/2011 17/01/2011
> 19/01/2011 19/01/2011
> 6. 16/01/2011 17/01/2011 20/01/2011 27/01/2011 23/01/2011
> 28/01/2011 14/02/2011
> 7. 23/01/2011 24/01/2011 24/01/2011 03/02/2011 24/01/2011
> 07/02/2011 21/02/2011
> 8. 28/01/2011 04/02/2011 06/02/2011 11/02/2011 07/02/2011
> 15/02/2011 26/02/2011
> 9. 28/01/2011 01/02/2011 02/02/2011 10/02/2011 01/02/2011
> 14/02/2011 01/03/2011
*
* 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/