Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

Re: st: Bar colors in graph

From   Nick Cox <>
Subject   Re: st: Bar colors in graph
Date   Tue, 21 Aug 2012 10:46:10 +0100

This is documented. See

Cox, N.J. 2011. Stata tip 102: Highlighting specific bars. Stata
Journal 11(3): 474-477.

Example code:

separate price, by(rep78 == 3)

graph hbar (mean) price0 (mean) price1 , over(rep78) bar(1,
color(blue)) bar(2, color(yellow)) ///
nofill legend(off) b2title(`: var label price') l1title(`: var label rep78')

On Tue, Aug 21, 2012 at 10:33 AM, Richard Ohrvall
<> wrote:

> I am creating some bar graphs where I would like fill some bars with a
> different color based on the values for some other variable (or in
> some cases the variable I use to create the groups). Eg. if I create
> the following graph
> sysuse auto, clear
> graph hbar (mean) price, over(rep78, sort(price) descending)
> I would like the bars to be blue except where rep78==3 in which case I
> would like them to be yellow. I assume there is some way to do this in
> some way, but I haven't found it. I could do it manually in the graph
> editor, but that is not a viable solution in  this case.
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index