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: RE: graph hbar - different colors for different groups defined by an external variables


From   Joe Canner <[email protected]>
To   "[email protected]" <[email protected]>
Subject   RE: st: RE: graph hbar - different colors for different groups defined by an external variables
Date   Fri, 20 Sep 2013 15:57:42 +0000

Ahhh...that makes more sense.  This is a bit beyond my experience, but perhaps you can use Nick Cox's example (http://www.stata.com/statalist/archive/2012-04/msg00376.html) as a starting point.  You will need to use -collapse- instead of -contract- since you are plotting means, and you will have to convert -regione- to a numeric variable to use -twoway bar- (which will then require some extra work to label the bars with the region name).  Finally, you will have to figure out how to associate the North/Central/South value with colors.

. collapse g0, by(regione geo)

Will give you a data set of means by region, with the -geo- variable along for the ride, which should help with this process.

If I come up with a more precise solution, I will respond again.


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Alice Guerra
Sent: Friday, September 20, 2013 11:17 AM
To: [email protected]
Subject: Re: st: RE: graph hbar - different colors for different groups defined by an external variables

Thank you Joe,

my command is

graph hbar (mean) g0, over(regione, sort(g0) descending label(labsize(vsmall)))

The graph that I would like to obtain have on the yaxis the name of the Italian regions, and the color of their bars should reflect their geographical position. For example, if the first region at the top of the y-axis  is Lombardy, and Sicily is the second one, I would like to color the first bar in black (color that corresponds to the North), and the second in gray (color of the South).

Thank you for your help

Alice

On 20 September 2013 17:07, Joe Canner <[email protected]> wrote:
> Alice,
>
> Try:
>
> . graph hbar yvar, over(geo) asyvars bar(1, color(black)) 
> bar(2,color(gray)) bar(3,color(white))
>
> Or were you hoping to have something more general that doesn't depend on knowing the ordering of the -geo-?
>
> Regards,
> Joe Canner
> Johns Hopkins University School of Medicine
>
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Alice 
> Guerra
> Sent: Friday, September 20, 2013 10:53 AM
> To: [email protected]
> Subject: st: graph hbar - different colors for different groups 
> defined by an external variables
>
> Dear Statalists,
>
> I was wondering if it would be possible to have different colors in a graph hbar for different groups. The groups are defined by an external variable.
>
> In my dataset, I have the Italian regions. I want to plot them in a graph hbar, and I want to color the bars of the Northern regions in black, the bars of the Southern regions in gray, and the central regions in white. the external variable for the geographic ripartition of regions is called "geo".
>
> Thank you for your time and help.
>
> Best regards
>
> Alice
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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