Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: how to overlap histograms


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: how to overlap histograms
Date   Tue, 21 Nov 2006 16:11:45 -0000

You say "overlap", but any overlapping is a property of 
the data rather than of graphical procedure. You 
can superimpose histograms, for example like this: 

sysuse auto, clear

twoway histogram mpg if foreign, ///
start(10) width(2) bcolor(none) blcolor(red) || ///
histogram mpg if !foreign ,     ///
start(10) width(2) bcolor(none) blcolor(blue)  ///
legend(order(1 "foreign" 2 "domestic") col(1) pos(1) ring(0))

but I find that in general the result is a mess: 

1. If distributions overlap, then necessarily one histogram
will partly occlude another. This can be reduced by 
for example setting bar colours to invisible, but it cannot
be eliminated. Perceiving the Gestalt is difficult even
for foresters accustoming to seeing the trees for the wood
and the wood for the trees. 

2. There is always the minor -- and sometimes the major --
worry of arbitrariness of bin width and origin. 

The histogram is 19th century technology: you can do 
much better with 1960s technology, namely the quantile-quantile
plot implemented as -qqplot-. 

Nick 
[email protected] 

Alejandro Delafuente
 
> am would like to overlap two histograms, 
> can anyone tell how 
> to do so? The code that I have produced so far is the 
> following, but it 
> displays two separate histograms with same scale magnitudes:
> 
> histogram CONTINUOUS VARIABLE if round!=1, percent 
> lcolor(red) ytitle(Percent 
> of households) xtitle(???) xlabel(0(.3)1, ticks) title(, 
> justification(center)) 
> note(, justification(center) alignment(top)) legend(off) 
> by(round, note
> (Difference in means test significant at 0.01% , size(vsmall) 
> justification
> (left)))

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index