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: Stacked bar chart with twoway
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Stacked bar chart with twoway
Date
Fri, 1 Nov 2013 15:42:24 +0000
I guess you are confusing the syntax of -graph bar- (which allows a
-stack- option) and -twoway bar-.
With -twoway- stacking of bars is achieved by using -twoway rbar- and
requires some preliminary work calculating the limits of each bar
segment.
Nick
[email protected]
On 1 November 2013 15:37, Likosky, Donald <[email protected]> wrote:
> I am trying to produce a stacked bar chart with the twoway command.
>
> The goal is to display differences in the proportion of two variables (trbc= _post_centername trbc_intra_centername ) for each of 70 hospitals. The hosp= itals would be on the x-axis, and the y-axis would be displaying proportion= s. I would like to display the graph as stacked bar chart for each medical = center. The code below color codes which hospital belongs to a particular g= roup (there are 4 groups with values of 1, 2, 3, 4).
>
> The code doesn't appear to work. I receive the following error:
> option stack not allowed
> r(198);
>
> Any ideas would be much appreciated.
>
> sort trbc_intra_centername
> twoway ( ///
> bar trbc_post_centername trbc_intra_centername if region_label=3D=3D1, stac= k percent fcolor(red) lcolor(red))) /// bar trbc_post_centername trbc_intra_centername if region_label=3D=3D2, stac= k percent fcolor(blue) lcolor(blue)) /// bar trbc_post_centername trbc_intra_centername if region_label=3D=3D3, stac= k percent fcolor(green) lcolor(green)) /// bar trbc_post_centername trbc_intra_centername if region_label=3D=3D4, stac= k percent fcolor(chocolate) lcolor(chocolate))) /// , ylabel(0(20)100, angle(horizontal)) ytitle(Percent) xtitle(Medical Center=
> ) title("Timing of Transfused Units" "by Medical Center" "AVR+/-CABG Surger=
> y") legend(on order(1 "Group 1" 2 "Group 2" 3 "Group 3" 4 "Group 4"))
>
*
* 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/