Bookmark and Share

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]

Re: st: Multiple single-variable stacked bar charts on the one axis


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Multiple single-variable stacked bar charts on the one axis
Date   Sun, 7 Apr 2013 14:07:03 +0100

Whatever Natalie does is likely to be much easier with a -reshape- of
the data so that the 10 variables become 1.

A little more detail on what is being plotted might help in suggesting
better displays, but -tabplot- (SSC) offers much of what people seek
in stacked bar charts without the concomitant disadvantages that David
and others have identified.

Nick
[email protected]


On 7 April 2013 13:15, David Hoaglin <[email protected]> wrote:
> Natalie,
>
> Stacked bar charts are usually an inferior way to display data.  The
> book by Naomi Robbins (2005) has an accessible discussion of some
> alternatives.  As a summary, it says, "Stacked bar chart: Do not use,
> because of their perceptual problems."  Better displays have been
> available in the literature on statistical graphics for some time.
> See, for example, the book by Cleveland (1985).
>
> David Hoaglin
>
> Cleveland, WS (1985).  The Elements of Graphing Data.  Wadsworth
> Advanced Books and Software.  (Revised edition: Hobart Press, 1994)
>
> Robbins, NR (2005).  Creating More Effective Graphs.  Wiley-Interscience.
>
> On Sun, Apr 7, 2013 at 5:54 AM, Natalie Herd
> <[email protected]> wrote:
>> 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/
*
*   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/


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