I'm not entirely convinced.
-graph bar headroom trunk, over(foreign) blabel(group)-
produces something like this (which I should have put in my first message):
Domestic
________ Domestic
| | ________
| | | |
| | | |
Domestic | | Domestic | |
________ | | ________ | |
| | | | | | | |
_______________________________________________
Domestic Foreign
whereas
-graph hbar headroom trunk, over(foreign) blabel(group)-
produces something like this (except that it is laid out horizontally):
Foreign
________ Foreign
| | ________
| | | |
| | | |
Foreign | | Foreign | |
________ | | ________ | |
| | | | | | | |
_______________________________________________
Domestic Foreign
Yes, individual bars are labeled (which is my deserved punishment), so this way of labeling stacked bars with their group name will not work (the label will appear twice). But no, the actual labels do not make sense as long as there is more than one y variable to deal with. I would have expected D-D-F-F instead of D-D-D-D with -bar- and F-F-F-F with -hbar-. In the case of one y variable,
-graph [h]bar headroom, over(foreign) blabel(group)-
it works out fine.
-- H�kon
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Nick Cox
Sent: 13. september 2004 13:45
To: [email protected]
Subject: RE: st: blabel(group) for bar graphs
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/
*
* 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/