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   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: percentage label with legend
Date   Sun, 29 Apr 2012 10:50:55 +0100

"somewhere while googling" is a fairly vague reference, but the
apparent contradiction can easily be resolved.  -graph, pie- was the
syntax before Stata 8; in Stata 8 upwards the commands

webuse auto
tabulate foreign, generate(f)
graph7 f1 f2, pie

will automatically produce labels with percents explicit.

I wrote a -pieplot- (SSC) which is a convenience wrapper for -graph,
pie- so that for example

pieplot foreign, percent

shows percents. However, it does not support what Tashi wants. In my
view legends are at best necessary evils, so I try to lose them, not
add more information to them.

As in previous threads, this is all a matter of taste, but what Tashi
is doing is in my view much better done using a bar or dot chart.

On Sun, Apr 29, 2012 at 7:01 AM, Eric Booth <[email protected]> wrote:

> 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'))
> *********!

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

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

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