Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: different color for each bar in a bar graph


From   Shehzad Ali <drshehzad_ali@yahoo.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: different color for each bar in a bar graph
Date   Tue, 10 Apr 2012 17:52:49 +0100 (BST)

Thanks, both. Very helpful. 


I also noticed that the graph editor also allows you to edit each bar separately, which is a helpful feature if you have a limited number of bars.

Thank you
Shehzad




>________________________________
> From: Kieran McCaul <kieran.mccaul@uwa.edu.au>
>To: "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> 
>Sent: Tuesday, 10 April 2012, 1:04
>Subject: RE: st: different color for each bar in a bar graph
> 
>...
>this line:
>local call `call' || bar _freq`j' rep78 , bcolor(gs`col')
>should be:
>local call `call' bar _freq`j' rep78 , bcolor(gs`col') ||
>
>
>-----Original Message-----
>From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
>Sent: Tuesday, 10 April 2012 2:29 AM
>To: statalist@hsphsun2.harvard.edu
>Subject: Re: st: different color for each bar in a bar graph
>
>Yes. Just call -twoway bar- repeatedly with each colour you want.
>
>Example:
>
>sysuse auto, clear
>contract rep78
>separate _freq, by(rep78)
>
>forval j = 1/5 {
>       local col = 3 *  `j'
>       local call `call' || bar _freq`j' rep78 , bcolor(gs`col')
>}
>
>twoway `call', ytitle(Frequency)
>
>See also
>
>Cox, N.J. 2011. Highlighting specific bars. Stata Journal 11: 473-477.
>
>On Mon, Apr 9, 2012 at 6:21 PM, Shehzad Ali <drshehzad_ali@yahoo.com> wrote:
>
>> Is it possible to specify a different bar color for each bar or sets of bars in a bar graph?
>> twoway (bar var1 var2)
>*
>*   For searches and help try:
>*  http://www.stata.com/help.cgi?search
>*  http://www.stata.com/support/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index