# Re: st: overlapping histograms

 From Nick Cox To statalist@hsphsun2.harvard.edu Subject Re: st: overlapping histograms Date Tue, 30 Sep 2008 10:48:53 -0500

```Or, more naturally,

gen gpm1 = 1/mpg1
gen gpm0 = 1/mpg0
qqplot gpm0 gpm1

i.e. the reciprocals of mpg differ by an additive shift.

Nick Cox wrote:
```
It is good to know that you can do this. My guess is that many users would like to see it written up somewhere.

However, these histograms tend to lead only to crude inferences. Users can't read off quantitative conclusions from the graph, just stuff like "The distributions are about the same", or "... very different", etc.

. separate mpg, by(foreign) veryshortlabel

. qqplot mpg1 mpg0

. qqplot mpg1 mpg0, xsc(log) ysc(log)

That is the start of a story: the distributions differ multiplicatively,
etc. Numbers can be then worked out.

Nick

Svend Juul wrote:

```Jeph wrote - in a comment to several suggestions:

More like this:

sysuse auto

twoway ///
(histogram mpg if foreign, bin(10) gap(5) fc(gray) lc(black)) ///
(histogram mpg if !foreign, bin(10) gap(15) fc(white) lc(black)) ///
legend(off)

It works better when there are more bins, ie, more obs - I have 100k
obs so I have lots of thin bars. The effect is quite good, though
I dislike that, as here, one distribution has thinner bars than the
other.

================================================================

twoway ///
(histogram mpg if !foreign, start(10) width(2) fc(white) lc(black)) ///
(histogram mpg if foreign, gap(50) fc(gray) lc(black) start(10)
width(2)) ///
, legend(off) plotregion(margin(b=0))

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