Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: label in -graph bar-


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: label in -graph bar-
Date   Tue, 22 Sep 2009 20:54:15 -0500

The -relabel()- suboption should be within the over() option:

sysuse auto,clear
graph bar (mean) mpg, over(rep, relabel(1 "2004-05" 2 "2005-06" 3
"2006-07" 4 "2007-8" 5 "2008-09"))


If you had multiple y variables you would then use the
-yvaroptions(relabel())- to change the labels on the axis.  For
example:

sysuse auto,clear
graph hbar (mean) mpg gear,   yvaroptions( relabel(1 "Mean of MPG" 2
"Mean of Gear")) ascategory

Scott


On Tue, Sep 22, 2009 at 8:01 PM, Sue <[email protected]> wrote:
> Dear Statalisters,
>
> I'm running the following command but have trouble getting the label
> on the xaxis correct. I want to relabel it as shown in the
> parentheses, but it just shows the years as is.
> So instead of displaying "2004-05", it displays "2005", etc. Can
> someone please tell me what's wrong with the code? Your help is
> greatly appreciated.
>
>  foreach var in realloangrowth realdepositgrowth   {
>  local v1: variable label `var'
>  graph bar (mean) `var', label ///
>  yvaroptions(relabel(2005 "2004-05" 2006 "2005-06" 2007 "2006-07"
> 2008 "2007-08")) ///
>  over(year, label(labsize(vsmall))) ytitle(`v1') ///
>  bargap(2) b1title("Year") by(ctype, title("`v1' by cgroup")) ///
>  /*graph export `var'_pre.png, replace*/
>  }

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