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

From |
Donald Spady <dspady@ualberta.ca> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: Problems with graphing in Stata 8 |

Date |
Mon, 23 Feb 2004 11:59:52 -0700 |

Branko

Try this

twoway (kdensity HbH if sex==1) (kdensity HbH if sex==2, legend(order(1 "male" 2 "female")))

I am unsure just how the 'order' part works, but it is necessary.

Don

At 11:45 AM 2/23/2004, you wrote:

Donald SpadyNick, What would be the way to do exactly the same thing as asked by Donald but using kdensity instead of scatter. That is, I need to have (say) kdensity fct for sex=1 and then for sex=2 and I want the two to be overlaid. The commands that I used in Stata 7 do not work in Stata 8. Thanks. Branko Milanovic ----- Original Message ----- From: "Nick Cox" <n.j.cox@durham.ac.uk> To: <statalist@hsphsun2.harvard.edu> Sent: Monday, February 23, 2004 1:16 PM Subject: RE: st: RE: Problems with graphing in Stata 8 > You don't have to do it this way. As said, > you can approach it from the direction you > started from. Something like > > twoway (scatter HbL HbH if sex==1, ms(Oh)) (scatter HbL HbH if > sex==2, ms(D) legend(order(1 "male" 2 "female"))) > > should work. The difference is between overlaying two > graphs and drawing one. When it is more like a matter > of overlaying five or six graphs, the issue takes > on a different shape. > > By the way, what you're puzzled by is not a graphical > issue. If you > > . list HbL HbH if sex == 1 > > the condition "if sex == 1" is left on the command > line and not echoed in the output in any direct way, > although it does affect the results you get. > > Nick > n.j.cox@durham.ac.uk > > Donald Spady > > > > It works. Seems a rather roundabout way to do this, having > > to create new > > variables, but it works. > > Many thanks > > > >Some recent threads have touched on this > > >question. > > > > > > >From Stata's point of view both graphs are > > >graphs of -HbL- versus -HbH-. -sex- is merely > > >the criterion you used to select points and > > >it doesn't feature in the graph. Why should > > >it? Both -if- conditions are upstream filters > > >determining what gets passed to the graph-drawing > > >commands. > > > > > >What you did can be tweaked to get what you > > >want, but for similar problems I favour this > > >kind of approach (and indeed -separate- was > > >written largely for this purpose): > > > > > >separate HbL, by(sex) > > >scatter HbL? HbH , legend(order(1 "male" 2 "female")) > > > > > >Nick > > >n.j.cox@durham.ac.uk > > > > > >Donald Spady > > > > > > > > when I plot twoway (scatter HbL HbH if sex==1) (scatter HbL HbH if > > > > sex==2) I expect to get an overlaid plot with corresponding > > > > HbL & HbH > > > > having one symbol if sex==1 and another symbol if sex == 2. I get > > > > different symbols, but in the legend box I get a blue diamond > > > > signifying > > > > HbL and a brown diamond signifying HbL. That's right, both > > > > signify HbL > > > > and neither one signifies sex, which I expected. What is > > > > going on? What > > > > am I doing (or interpreting) wrong? > > * > * 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/ > * * 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/

Department of Pediatrics

2C3.92 WMC, University of Alberta

Edmonton, Alberta, Canada

T6G 2R7

780-407-1244:O

780-407-7136:F

Nature has no reset button.

*

* 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/

**References**:**RE: st: RE: Problems with graphing in Stata 8***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Problems with graphing in Stata 8***From:*"Branko Milanovic" <bmilanovic@ceip.org>

- Prev by Date:
**Re: st: RE: Problems with graphing in Stata 8** - Next by Date:
**st: collapse** - Previous by thread:
**Re: st: RE: Problems with graphing in Stata 8** - Next by thread:
**RE: st: RE: Problems with graphing in Stata 8** - Index(es):

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