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: hbar graph & colour


From   Sergiy Radyakin <[email protected]>
To   [email protected]
Subject   Re: st: hbar graph & colour
Date   Sat, 19 Feb 2011 22:37:46 -0500

Dear Maria,

see if this works for you:

*************************************************************************************************************
clear

input country gdp gdpblue gdpred gdpgreen
1	100	100	.	.
2	110	.	.	110
3	240	.	240	.
4	50	50	.	.
5	10	10	.	.
end

graph hbar gdpred gdpgreen gdpblue, over(country, sort(gdp)
descending) nofill ///
  legend(label(1 "Best") label(2 "2nd best") label(3 "rest") rows(1)) ///
  bar(1, color(cranberry)) bar(2, color(dkgreen)) bar(3, color(dknavy))

*************************************************************************************************************

Best,
  Sergiy Radyakin





On Sat, Feb 19, 2011 at 8:57 PM, María Edo <[email protected]> wrote:
> Hello,
>
> I need to construct a horizontal bar graph using three colours: two
> different colours to highlight two particular bars (say, red and
> green) and one colour for the rest of the bars (say, blue).
>
> So far, I have managed to get two colours in the graph by using the
> -over- option:
>
> input country   gdp   flag1 flag2
> 1  100    0       0
> 2  110    0       1
> 3  240    1       0
> 4  50     0       0
> 5  10     0       0
> end
> graph hbar  gdp, asyvars over(flag1) over(country, sort( gdp)
> descending) bar(1, color(blue)) bar(2, color(red)) stack
>
> To get the graph I need, country "2" should appear in green.
>
> I am sure there is a trivial way of achieving this, but I haven't been
> able to find it.
> Many thanks,
>
> Maria
> *
> *   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/


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