Statalist The Stata Listserver


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

Re: st: RE: Stacked Histogram


From   Marcello Pagano <[email protected]>
To   [email protected]
Subject   Re: st: RE: Stacked Histogram
Date   Wed, 25 Oct 2006 12:39:55 -0400

Apologies for not responding sooner, but I was flying yesterday. From our nation's capital, let me say your solution works beautifully. Thank you very much.

Yes, I agree, I only used it for a few (two) categories. Probably get too confusing for too many more.

Thanks, again,

m.p.

Quoting Nick Cox <[email protected]>:


The generic problem I think of here as "the way ahead is -bar-red",
meaning that -graph bar- or -histogram- doesn't do it, so what is
to be done? The answer is (usually) to make your own with -twoway bar-
as a basis.

Here is an example:

sysuse auto, clear

twoway__histogram_gen mpg if foreign, gen(freq_foreign x) freq start(0) width(2)

twoway__histogram_gen mpg if !foreign, gen(freq_domestic x2) freq start(0) width(2)

qui gen freq = freq_domestic + freq_foreign

twoway bar freq_domestic x if freq < ., barw(2) bcolor(blue) xsc(r(10 .)) || ///
rbar freq_domestic freq x2 if freq < ., barw(2) bcolor(red) ///
legend(order(1 "Domestic" 2 "Foreign") pos(11) col(1) ring(0)) ///
xtitle("`: var label mpg'") ytitle(Frequency) xla(10(5)40) yla(, ang(h)) ///
xsc(r(10 .))


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