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

Re: st: RE: Combining histograms

 From Michael Hecker To statalist@hsphsun2.harvard.edu Subject Re: st: RE: Combining histograms Date Sat, 21 May 2011 00:39:54 +0200

```Deal Nick,
thank you very much. This looks like a very good starting point.

Thanks,
Michael

Am 20.05.2011 20:50, schrieb Nick Cox:
```
```"combine", "merge" both admit of different interpretations.

You can use -graph combine-. You don't say what you typed or in what sense you "didn't manage to get the result".

Otherwise I'll guess that you want to superimpose histograms.

You can do that in various ways. Often it's hard work to stop bars of one variable occluding bars of the other variable.

sysuse auto, clear

twoway histogram trunk, width(2) start(0) bfcolor(none) blcolor(blue) freq
|| histogram mpg, width(2) start(0) bfcolor(none) blcolor(red) barw(1.7) freq legend(order(1 "`: var label trunk'" 2 "`: var label mpg'"))

This is a 19th century way of comparing distributions. -qqplot- gives you a 20th century method with no binning choices or artefacts.

Nick
n.j.cox@durham.ac.uk

Michael Hecker

I create two histograms using:

hist X, saving(normal, replace)
hist Y, saving(changed, replace)

Is it possible two merge both gph-files into a single graph?
I didn't manage to get the result with "graph combine".
I want to have both histograms in a single chart to compare the
distributions.

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