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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: AW: AW: Problematic twoway lineplot with -by- |

Date |
Thu, 13 Aug 2009 20:15:36 +0200 |

<> And if you are totally in love with it, check out -seperate- HTH Martin -----Original Message----- From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox Sent: Donnerstag, 13. August 2009 19:20 To: statalist@hsphsun2.harvard.edu Subject: RE: st: AW: AW: Problematic twoway lineplot with -by- If you like -separate- check out SJ-5-4 gr0023 . . . . Stata tip 27: Classifying data points on scatter plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/05 SJ 5(4):604--606 (no commands) tips for using separate, gray-scale gradation, and text characters as class symbols to classify data points on a scatter plot Accessible to all at http://www.stata-journal.com/sjpdf.html?articlenum=gr0023 Nick n.j.cox@durham.ac.uk Steinar Fossedal Thank you, Martin! -separate- was quite the nugget for my repetoire, it will help a lot in the future. 2009/8/13 Martin Weiss <martin.weiss1@gmx.de>: > Last two lines should be > > > ************* > gr combine graph1 graph2, /* > */ rows(1) > ************* > > These things do not always transfer well... Martin Weiss > ************* > // Create dataset > clear* > set obs 40 > gen id = int((_n-1)/10)+1 > gen group = (id>=3) + 1 > bysort id: gen time = _n > replace time = time -.5 if id == 4 > gen value = uniform() > bysort id (time): replace value = /* > */ value[_n-1] + uniform() if _n > 1 > > > separate value if group==1, by(id) > > tw (line value1 time if group==1, sort) /* > */ (line value time if group==2, sort), /* > */ legend(off) nodraw > > graph rename graph1 > > tw (line value2 time if group==1, sort) /* > */ (line value time if group==2, sort), /* > */ legend(off) nodraw > > graph rename graph2 > > gr combine graph1 graph2, > rows(1) > ************* Steinar Fossedal > I'm trying to create a twoway graph using two line graphs, and have it > split into groups using -by- _on_only_one_of_the_graphs_. I'm finding > this a bit tricky to pull off, and I've cooked up an example below > which illustrates the problem. My goal is to have graph 2 included on > each of the plots in graph 1, resulting in a graph with two plots > having two lines each. Instead, I get a graph with four plots in it, > and only a single line per plot. > > Is there any way to produce the graph that I want without rearranging my data? > > Example : > > // Create dataset > clear > set obs 40 > gen id = int((_n-1)/10)+1 > gen group = (id>=3) + 1 > bysort id: gen time = _n > replace time = time -.5 if id == 4 > gen value = uniform() > bysort id (time): replace value = value[_n-1] + uniform() if _n > 1 > > // Create plots > // Graph 1 (using by) > twoway (line value time if group==1, sort by(id)) > graph rename graph1 > // Graph 2 (not using by) > twoway (line value time if group==2, sort) > graph rename graph2 > // Graph 3 (Attempt to merge the two graphs together, getting graph 2 > on each of the plots in graph 1) > twoway (line value time if group==1, sort by(id)) (line value time if > group==2, sort) > graph rename graph3 * * 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/ * * 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/

**References**:**st: Problematic twoway lineplot with -by-***From:*Steinar Fossedal <steinar.fossedal@gmail.com>

**Re: st: AW: AW: Problematic twoway lineplot with -by-***From:*Steinar Fossedal <steinar.fossedal@gmail.com>

**RE: st: AW: AW: Problematic twoway lineplot with -by-***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**RE: st: Principal Components Analysis with count data** - Next by Date:
**st: VIFs under SVY command and -collin- command** - Previous by thread:
**RE: st: AW: AW: Problematic twoway lineplot with -by-** - Next by thread:
**st: hausman test** - Index(es):

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