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

# Re: st: Adding normal density to overlayed histograms

 From "Michael N. Mitchell" <[email protected]> To [email protected] Subject Re: st: Adding normal density to overlayed histograms Date Wed, 20 Oct 2010 22:57:28 -0700

```Dear Dorothy

```
The documentation for -help addplot_option- indicates that the -addplot()- option shows that it works like this...
```
. sts graph, addplot(your_contribution)

the result is that the commands construct

. graph twoway something_complicated || your_contribution

so your command would translate into

. graph twoway hist x, normal || hist x2, normal

```
but, unfortunately, -normal- is not a supported option for -graph twoway-, it is only supported for -hist- alone.
```
```
Using the -auto- dataset as an example, here is a long way you can create an overlaid histogram of -weight- and -price- with a normal overlay for each...
```
- snip -
sysuse auto, clear

hist weight, addplot(hist price)

summarize weight
local m1 = r(mean)
local s1 = r(sd)

summarize price
local m2 = r(mean)
local s2 = r(sd)

graph twoway (histogram weight) ///
(histogram price) ///
(function normden(x,`m1',`s1'), range(weight)) ///
(function normden(x,`m2',`s2'), range(price))
- snip -

I hope that helps,

Best regards,

Michael N. Mitchell
Data Management Using Stata      - http://www.stata.com/bookstore/dmus.html
A Visual Guide to Stata Graphics - http://www.stata.com/bookstore/vgsg.html
Stata tidbit of the week         - http://www.MichaelNormanMitchell.com

On 2010-10-20 9.39 PM, Dorothy Bridges wrote:
```
```Hi everyone,

I am overlaying two histograms and would like Stata to add a normal
density curve for each.

hist x, normal addplot(hist x2)

works fine, but

hist x, normal addplot(hist x2, normal)

tells me that normal is not an option.  Any ideas as to why this is happening?

Thanks,
Dorothy
*
*   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/
```