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]
st: RE: Graph bar with label wtih % symbol at the top of each bar
From
"David Radwin" <[email protected]>
To
<[email protected]>
Subject
st: RE: Graph bar with label wtih % symbol at the top of each bar
Date
Thu, 10 May 2012 15:08:03 -0700 (PDT)
Marcos,
I don't think you can get the percentage symbol (%) to show, but you can
get the number to show as a percentage if you first multiply your binary
variables by 100, perhaps creating new variables, such as:
. foreach v of varlist var1 var2 var3 {
. gen `v'_pct = 100 * `v'
. }
A nice shortcut for labeling your axis is Nick Cox's -mylabels- from SSC.
Don't use the -myscale(@/100)- option in the example below if you first
multiply by 100 as in the example above.
. mylabels 0(20)100, myscale(@/100) local(pctlabel) suffix("%")
. graph bar (mean) var1 var2 var3, ylab(`pctlabel')
David
--
David Radwin
Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794
www.mprinc.com
> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Marcos Vinicius
> Sent: Thursday, May 10, 2012 2:56 PM
> To: [email protected]
> Subject: st: Graph bar with label wtih % symbol at the top of each bar
>
> Hello,
> I used the following code to plot a graph representing 3 binary
variables
> with ylabel to change the percentage representation.(20% instead of
> 0.20) and blabel to show the label at the top of each bar. My question:
> How to get a percentage representation like 20% (instead of 0.20 ) for
> the label at the top of each bar ?
>
> graph bar (mean) var1 var2 var3 , bargap(20)
> yvaroptions(relabel(1 "text1 " 2 " text2" 3 "text3" )) blabel(bar
> ,position(outside) format(%4.2f)) ytitle("") ylabel( 0 "0" .2 "20%"
.4
> "40%" .6 "60%" .8 "80%" 1 "100%", angle(horizontal)) title("text4")
> Best regards.
> Marcos.
*
* 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/