Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: blabel(group) for bar graphs


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: blabel(group) for bar graphs
Date   Mon, 13 Sep 2004 12:45:29 +0100

On -blabel()-: try the principle that your punishment 
is that you got precisely what you asked for. 

That is, -blabel()- labels _individual_ bars. You 
want to label groups of bars. The presumption in 
-graph bar- appears to be that the natural place to 
do that is via text outside the category axis, and on the whole 
I agree with that presumption. More importantly, -graph bar-
does not offer a kind of group label option, which 
appears to be what you want. 

Nick 
[email protected] 

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Finne H�kon
> Sent: 13 September 2004 12:11
> To: [email protected]
> Subject: RE: st: blabel(group) for bar graphs
> 
> 
> Thanks, Nick -
> 
> it's amazing what the trained eye can do with Stata's 
> graphing capabilities and your solution responds precisely to 
> the way I formulated the question for vertical bar charts. 
> With a little tweaking, I can even accommodate it for 
> stacking the bars in many cases and orient the bars 
> horizontally (which was my original point of departure).  
> Nevertheless, the -blabel(group)- behavior when more than one 
> yvar is involved still strikes me as odd.
> 
> -- H�kon
> 
> 
> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Nick Cox
> Sent: 13. september 2004 11:51
> To: [email protected]
> Subject: RE: st: blabel(group) for bar graphs
> 
> 
> If -graph bar- doesn't show the flexibility you want 
> one option is to knit your own with -twoway bar-. 
> 
> Here is a long way round: 
> 
> collapse (mean) headroom trunk, by(foreign) 
> gen foreign1 = foreign - 0.1
> gen foreign2 = foreign + 0.1
> gen max = max(headroom, trunk) 
> twoway bar headroom foreign1 , barwidth(0.2) 
>     || bar trunk foreign2 , barwidth(0.2) 
>     || scatter max foreign , ms(none) mlabel(foreign) 
> mlabpos(12) xla(none)  
> 
> Nick 
> [email protected] 
> 
> H�kon Finne
>  
> > Thanks for the suggestion, Phil; but no; I actually want the 
> > group name and not the variable name (because I later want to 
> > remove the label on the category axis due to space 
> > considerations). The problem is that the group label is 
> > incorrect once there is more than one yvar.
> 
> Philip Ryan
>  
> > By specifying -blabel(group)- you have asked Stata to label 
> > the bars with 
> > the value labels of the first (and in your case, only)  
> > over()  variable, 
> > that is, foreign.
> > 
> > Specifying -blabel(name)- will get you closer to what I think 
> > you want.
> > 
> > see help graph -- bar --blabel_options
> 
> H�kon Finne
>  
> > the admittedly nonsensical example below,
> > 
> > sysuse auto, clear
> > graph bar headroom trunk, over(foreign) blabel(group)
> > 
> > will produce bar labels inconsistent with labels on the 
> > category axis. 
> > What have I done to make all cars domestic?
> > 
> > One should also think it possible to reproduce this behavior with
> > 
> > graph hbar headroom trunk, over(foreign) blabel(group)
> > 
> > and yet another surprise -- have I suddenly moved abroad?
> > 
> 
> *
> *   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/
> 
> *
> *   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/
> 

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