Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Svend Juul <SJ@soci.au.dk> |
To | "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: Plotting normal distributions |
Date | Thu, 7 Jun 2012 14:08:04 +0200 |
Amal wrote: I would like to plot normal distributions of birth weight by nationality in the same graph for comparison, using different colours. I wasn't able to figure out how to do this. What I've managed so far is to plot each birth weight distribution separately in small graphs and get it together as one image using the basic histogram command: hist BW, by (motherland) I have 19 nationalities. Not sure how many different colours Stata permits - but maybe a combination of colours and schemes (liked dashed lines) is needed? ================================================================= Nick gave, as usual, sensible advice and warnings. But anyway, I want to point to -kdensity-. Try this: -------------------------------------------------------- webuse lbw.dta, clear kdensity bwt if race==1 , generate(x_white y_white) kdensity bwt if race==2 , generate(x_black y_black) kdensity bwt if race==3 , generate(x_other y_other) twoway (line y_white x_white, sort) /// (line y_black x_black, sort) /// (line y_other x_other, sort) /// , legend(order(1 "White" 2 "Black" 3 "Other")) -------------------------------------------------------- Think of -kdensity- curves as smoothed histograms. They may be what you want. Hope this helps Svend _______________________ Svend Juul sj@soci.au.dk<mailto:sj@soci.au.dk> * * 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/