Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Plotting normal distributions

From   Svend Juul <>
To   "" <>
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 Juul<>

*   For searches and help try:

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