Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Multiple single-variable stacked bar charts on the one axis
From
Natalie Herd <[email protected]>
To
[email protected]
Subject
st: Multiple single-variable stacked bar charts on the one axis
Date
Sun, 7 Apr 2013 19:54:11 +1000
Hi Statalist!
I am trying to create a stacked bar chart of 10 categorical variables
(3 categories per variable) on a single axis (i.e., 10 separate bars,
with the %s for each of the 3 categories stacked on top of one
another).
The variables are fit1_cat thru fit10_cat.
I have tried the following options:
1) I can get a single stacked bar for one variable by using the
following syntax:
tab fit1_cat,g(fit1_cat_v2)
graph hbar fit1_cat_v21-fit1_cat_v23, stack percent l1title(var 1)
2) Alternatively, I can also get a single stacked bar using catplot:
catplot fit1_cat, asyvars stack percent l1title(var 1)
3) The final approach I have tried is running the 10 stacked bar
charts separately and then using grc1leg to combine them:
grc1leg c1.gph c2.gph c3.gph c4.gph c5.gph c6.gph c7.gph c8.gph c9.gph
c10.gph, cols(1) imargin(0 0 0 0) ycommon xcommon legendfrom(c2.gph)
Unfortunately, this last approach squashes the bottom bar due to the
presence of the y scale (something that I have excluded from all of
the other bars). I could just have no y scale, but that would not be
ideal.
Is there a better way to achieve this type of chart?
As an aside, is it possible to change the angle of the bar label
l1title, so that it runs horizontally rather than vertically?
Thanks, Natalie
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/