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: different color for each bar in a bar graph


From   Nick Cox <[email protected]>
To   [email protected]
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 <[email protected]> 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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index