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 at the end of May, 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   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: different color for each bar in a bar graph
Date   Mon, 9 Apr 2012 19:29:22 +0100

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/


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