Bookmark and Share

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: percentage label with legend


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: percentage label with legend
Date   Sun, 29 Apr 2012 01:01:01 -0500

<>

The command syntax is "graph pie [varlist]",     not "graph [varlist], pie".  See -help graph pie-

*********!
   webuse auto, clear

   tabulate foreign, generate(f)

*manually changing the legend
graph pie f1 f2, plabel(_all percent) ///
	 legend(order(1 "Overridden Label and adding 50%"  2 "Overridden Label two"))


*automatically changing the lables
loc i = 1
foreach x of varlist f? {
	qui summarize `x', detail
	loc a = string(`r(mean)'*100)+ "%"
	loc j `" `j' `i' "`:var l `x'' `a'"  "'
	loc i `++i'
	}
	di `"`j'"'
	
graph pie f1 f2, plabel(_all percent) ///
	 legend(order(`j'))
*********!

- Eric


__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754


On Apr 28, 2012, at 7:21 PM, tashi lama wrote:

> 
> Hello, 
> 
>     I am aware of stata's ability to create percentage labels on the slices. I am more interested to have my percentage labels side by side with the legends. I actually saw somewhere while googling where they used the following to create percentage labels on the legend
> 
> 
> 
>    webuse auto
> 
>    tabulate foreign, generate(f)
> 
>    graph f1 f2, pie
> 
> 
> 
> I tried doing  similar, but wasn't successful. I guess my question is if there is a way to create a label with the legends, not on the slices? Any lead will be highly appreciated.
> 
> 
> 
> Thanking,
> 
> Tashi 		 	   		  
> *
> *   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index