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
Kieran McCaul <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: different color for each bar in a bar graph
Date
Tue, 10 Apr 2012 08:04:38 +0800
...
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: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: Tuesday, 10 April 2012 2:29 AM
To: [email protected]
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 <[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/
*
* 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/