Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: graph bar: coloring one bar in a different color


From   Harry Telser <[email protected]>
To   [email protected]
Subject   st: graph bar: coloring one bar in a different color
Date   Wed, 20 Sep 2006 12:34:50 +0200

Hi everyone,

My problem is that I want to color one bar in graph bar in a different color than the rest.
For example, in this graph:

sysuse nlsw88
graph hbar wage , over(industry, sort(1))

I want to highlight the bar for "Construction" by coloring it red. I know that I can do this by using the -asyvars- command:

graph hbar wage , over(industry, sort(1)) asyvars bargap(50) ///
bar(1, bcolor(navy)) ///
bar(2, bcolor(navy)) ///
bar(3, bcolor(red)) ///
bar(4, bcolor(navy)) ///
bar(5, bcolor(navy)) ///
bar(6, bcolor(navy)) ///
bar(7, bcolor(navy)) ///
bar(8, bcolor(navy)) ///
bar(9, bcolor(navy)) ///
bar(10, bcolor(navy)) ///
bar(11, bcolor(navy)) ///
bar(12, bcolor(navy)) legend(off)

However, I wondered if there is an easier solution. My dataset consists of over 50 firms and I want to draw individual graphs for each firm (always highlighting the bar corresponding to this firm). Do I really have to indicate the color of each bar in each graph separately? Or is there a more elegant way to do this? (Note that I do not need a legend, since the individual firm should only know which bar is her own).

Thank's in advance for your help.

Harry


--
***
Dr. Harry Telser
Socioeconomic Institute
University of Zurich
Hottingerstr. 10
CH-8032 Zurich

phone: +41 1 634 06 07
fax: +41 1 634 49 87
mail: [email protected]
web: http://www.soi.unizh.ch/staff/telser/index2.html
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index