Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

Re: st: only display top 5 results in pie graph


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: only display top 5 results in pie graph
Date   Mon, 16 Apr 2012 20:01:08 +0100

My main suggestion is that you would be better off with a horizontal
bar chart, which would show 20 or so bars without much difficulty,
quite apart from other advantages.

That said, some technique can be gleaned from this example.

sysuse auto, clear
collapse (sum) price-foreign
xpose, clear varname
gsort -v1
graph pie v1 in 1/5, over(_varname) sort

su v1
local sumall = r(sum)
su v1 in 1/5
replace v1 = `sumall' - r(sum) in 6
replace _varname = "others" in 6
graph pie v1 in 1/6, over(_varname) sort

Nick

On Fri, Apr 13, 2012 at 4:43 PM, tashi lama <ltashi32@hotmail.com> wrote:

      I have a dataset containing 15 variables. When I draw a pie
chart, it looks really messy because of large no of variables. Does
anyone have any idea to have a pie chart displaying only the top 5
results? Rank is total values of observations. Thanks in advance..

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index