Statalist


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

RE: st: Pie Chart Color Scheme


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: Pie Chart Color Scheme
Date   Thu, 15 Jan 2009 20:42:40 -0000

This refers to -spineplot- from the SJ. 

You need to -generate- your own. 

I thought of adding something like that to -spineplot-, but 

1. Life is short. Something else supervened. 

2. Sometimes it seems a better contribution not to add more options and
further complicate a command, especially if there are several
possibilities that suggest themselves and users can do it upstream of a
command anyway. 

Suppose for example you went 

. sysuse auto 
. bysort foreign rep78 : gen freq = _N 
. by foreign : gen colfreq = _N 
. bysort rep78 : gen rowfreq = _N 
. count if !missing(foreign, rep78) 
. local total = r(N) 

Then you can -generate- percents: 

. gen percent = 100 * freq / `total' 
. gen rowpercent = 100 * freq / rowfreq 
. gen colpercent = 100 * freq / colfreq 

In practice, you will want to -round()- to the nearest percent or to one
decimal place. Often, you will want to make the text crisp and clear by
adding a call to option -mlabsize()-. 

If you only want to plot a subset of observations, do this kind of thing

between 

. preserve 
. keep if <interesting and useful> 

and 

. restore 

Nick 
[email protected] 

[email protected]

Thanks.
Is there an easy way to get percentages in the middle of each of those  
boxes? Or do I have to generate my own and use text()?

--- Maarten buis <[email protected]> wrote:

> A nice alternative is the spineplot (implemented in Stata by Nick
> Cox)

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