As Don implies, Branko's problem is
essentially the same.
Let's backtrack one step and look at the general
choice here. The graph overlay
facility is wonderful, but not always the
only solution, or even the best. There's
often a choice between fixing things upstream
(generating separate variables ahead of the graph)
and fixing things on the fly.
If I had say five density estimates to superimpose,
I would be tempted to do something like this
forval i = 1/5 {
qui kdensity myresponse if mygroup == `i', gen(density`i')
}
line density? , clp(dash dot solid dash_dot "_#-#")
legend(label(1 "group 1") label(2 "2") label(3 "3") label(4 "4")
label(5 "5"))
The example shows how -label()- is an alternative to -order()-
(and incidentally why you might prefer -order()-).
Of course, there is some inelegance in generating the
variables explicitly. The resulting graph command, however,
tends to be easier to write, to debug and to understand
afterwards.
Do whatever seems more straightforward.
Nick
n.j.cox@durham.ac.uk
Donald Spady to Branko Milanovic
> 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.
> >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.
*
* 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/