Statalist


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

Re: st: How to achieve invisible bars in -graph bar-?


From   "Sergiy Radyakin" <[email protected]>
To   [email protected]
Subject   Re: st: How to achieve invisible bars in -graph bar-?
Date   Wed, 30 Jul 2008 16:20:58 -0400

Hello Riley,

I guess you start like so:

sysuse auto
gen z=make!="AMC Spirit"
graph hbar mpg, over(z) over(make, sort(1) descending) bar(1,
color(red)) bar(2, color(green)) nofill asyvars legend(off)

Interestingly, individual bar colors can be adjusted after the graph
is drawn via the graph classes, but any changes then affect all bars
when the graph is redrawn to reflect the changes. Perhaps it is a
feature?

Also note that individual colors can be set in Graph editor (Stata 10).

Best regards, Sergiy Radyakin


On 7/30/08, Riley Newman <[email protected]> wrote:
> This is an interesting problem, related to some bar graphing I've been
> working on. Is it possible to change the color of only one bar within one
> yvar?
>
> i.e. if we want to highlight AMC Spirit in contrast with other cars:
>
> sysuse auto
> keep in 1/5
> graph hbar mpg, over(make, sort(1) descending) bar(1, color(green))
>
> Thanks!
>
> Riley
>
> [email protected]
>
>
>
> On Jul 30, 2008, at 10:06 AM, Nick Cox wrote:
>
> > When -graph bar- does not do what you want, it is usually best to turn
> > to -twoway bar-.
> > So you needn't put even a notional bar where you just want text labels,
> > just use -twoway scatter- or -twoway scatteri- (e.g.).
> >
> > Nick
> > [email protected]
> >
> > Eva Poen
> >
> > I just realised that this attempt will be futile anyway. -graph bar-
> > with -(asis)- does not allow to label the bars with the label of
> > -yvar- which is what I wanted in the end. I will have to fiddle with
> > -twoway- to achieve what I want, I believe.
> >
> > I'm still curious why -bstyle(none)- does not do what it says, though.
> >
> > 2008/7/30 Eva Poen <[email protected]>:
> >
> >
> > > I am trying to achieve invisible bars in a -graph bar- chart. The idea
> > > is to show only the labels and not the bars themselves; all of this is
> > > part of my effort to add more information to a -graph bar- chart than
> > > Stata allows by default.
> > >
> > > However, I fail to render the bars invisible. After reading the help
> > > on barlook options, I concluded that the following should work:
> > >
> > > sysuse auto
> > > graph bar (mean) length turn, over(foreign)  bar(1, bstyle(none) )
> > >
> > > In Stata 9.2 and Stata 10, this still gives me the outline of the
> > > bars. No matter which combination of -bstyle-, -color-, -fcolor-,
> > > -lwidth-, -lcolor-, and -lstyle- I choose, I always end up with an
> > > outline around the bars.
> > >
> > > I find that confusing, since -help areastyle- notes for the style
> > > -none-: "no outline and no background color".
> > >
> > > Is there some way to omit the bars and only print the labels?
> > >
> >
> > *
> > *   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/
>
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index