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: Bar colors in graph


From   Richard Ohrvall <richard.ohrvall@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Bar colors in graph
Date   Tue, 21 Aug 2012 13:03:51 +0200

Thank you for prompt and very helpful reply. This was exactly what I
was looking for. Richard

2012/8/21 Nick Cox <njcoxstata@gmail.com>
>
> 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
> <richard.ohrvall@gmail.com> 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:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/




--
Richard Öhrvall
http://richardohrvall.com/
https://twitter.com/richardohrvall

*
*   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