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: Combining histograms

From   Ronan Conroy <>
To   "" <>
Subject   Re: st: Combining histograms
Date   Mon, 23 May 2011 10:07:44 +0100

On 2011 Beal 20, at 19:35, Michael Hecker wrote:

> Dear list,
> 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.

Histograms are not a great way of comparing distributions. 

sysuse auto
histogram mpg, bin(10) frequency
histogram mpg, bin(10) start (10) frequency
histogram mpg, bin(10) frequency
histogram mpg, bin(12) start (10) frequency
histogram mpg, width(2.5) frequency

Have a look at the resulting histograms, or use -combine- to pop them into a single chart. You will see that it is possible to change the appearance of a histogram very significantly by arbitrary choices of bin, start and width arguments, of which there are limitless combinations. Note, in particular, the last one, which uses bins of 2.5, thus creating a saw-toothed effect. 

If you can draw a large number of different histograms from the same data, how can you tell which differences between two histograms are due to data differences and which are due to differences in the underlying distribution?

Ronán Conroy
Associate Professor
Division of Population Health Sciences
Royal College of Surgeons in Ireland
Beaux Lane House
Dublin 2

*   For searches and help try:

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