[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
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)
> 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.
> 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
> 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: