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: graph hbar, over, and bar coloring


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: graph hbar, over, and bar coloring
Date   Wed, 2 Mar 2011 13:07:23 +0000

A detail that may be important to others is embedded within this
example of Stephen's.

sysuse auto, clear
gr hbar weight, over(foreign)
gr hbar weight, over(foreign) bar(1, color(black)) bar(2, color(gs8))

For those of you not intimately familiar with the auto dataset, I will
spell out that the first graph gives two bars of the same colour and
the second command changes them both to black. So, why not _two_
different colours, as apparently requested?

The detail is that the 1 and 2 (etc.) in the -bar()- options don't
identify bars; they identify the first _variable_ being plotted, the
second variable being plotted, and so forth.

You can get -graph hbar- to treat the groups as separate y variables
with the extra incantation "asyvars". Then, in this case, two colours
will be supplied (although the graph may not be to your taste, which I
will leave as a separate issue).

gr hbar weight, over(foreign) asyvars
gr hbar weight, over(foreign) asyvars bar(1, color(black)) bar(2, color(gs8))

Nick

>
> On Wed, Mar 2, 2011 at 11:49 AM,  <[email protected]> wrote:

[...]

>> For similar issues, cf.
>>
>> . sysuse auto, clear
>> (1978 Automobile Data)
>>
>> . gr hbar weight, over(foreign)
>>
>> . gr hbar weight, over(foreign) bar(1, color(black)) bar(2, color(gs8))
>>
>> I would have hoped that the bar coloring would cycle within the over
>> group, but it doesn't.

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