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: Different Label Positions for Different Bars in one Bar Chart
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: Different Label Positions for Different Bars in one Bar Chart
Date
Mon, 10 Sep 2012 23:27:47 +0100
You may need to switch to -twoway bar- to get this.
Some technique:
sysuse auto, clear
graph hbar mpg, over(foreign) asyvars ///
blabel(name, position(base)) bar(1,color(gs8)) bar(2,color(gs12)) name(hbar)
local xtitle "`: var label mpg'"
collapse mpg, by(foreign)
gen zero = 0
twoway bar mpg foreign if foreign, horizontal base(0) bcolor(gs8) ///
|| bar mpg foreign if !foreign, horizontal base(0) yla(0 1,
valuelabel) bcolor(gs12) yla(, noticks ang(h)) ///
|| scatter foreign mpg if foreign, ms(none) mla(foreign) ///
|| scatter foreign zero if !foreign, ms(none) mla(foreign) ///
legend(off) xla(0(5)25)xsc(r(. 30)) xtitle(`xtitle') name(twbar)
Nick
On Mon, Sep 10, 2012 at 9:56 PM, Jan Keil <[email protected]> wrote:
> Dear Statalist,
>
> I am trying to create an hbar chart where the labels are inside and at the base position for some bars while the labels of other bars are located outside.
> It seems to be the case that this can only be done for all bars at the same time. I did not find an easy way to do it but I am sure that there is a very trivial solution.
>
> The option for changing it for all graphs is blabel(name, position(base)).
>
> The whole command looks similar to this
>
> graph hbar costs, over(industry)
> asyvars blabel(name, position(base))
> bar(1,color(gs8)) bar(2,color(gs12))
>
>
>
> *
> * 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/