[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: Stacked Histogram
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.
Quoting Nick Cox <firstname.lastname@example.org>:
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
twoway__histogram_gen mpg if !foreign, gen(freq_domestic x2) freq
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)) ///
* For searches and help try: