On 10/16/07, Schonlau, Matthias <[email protected]> wrote:
> For programming new graphs in stata, Stata 7 offered the command "gph".
> This is still available under version control, but I believe the use of
> gph at this point is discouraged. (Right?)
>
> I am particularly interested in creating spine plots. These are plots
> similar to barcharts, but with the width proportional to frequency (and
> constant height). Barcharts work just the other way around.
Do you mean something like this?
sysuse auto,clear
graph bar (count) mpg, over(rep) name(gr1,replace)
collapse (count) mpg, by(rep)
keep if rep !=.
sum mpg
gen freq = mpg/r(sum)
gen f2 = fre
expand 2
bysort rep: gen t = _n
replace f2 = 0 if t == 1
gen sum = sum(fre) if t ==1
gen foo = 1
twoway area foo sum if rep <=1, color(gs12) ///
|| area freq sum if rep <=1 ///
|| area foo sum if rep <=2 & rep>1 , color(gs12) ///
|| area freq sum if rep <=2 & rep>1 ///
|| area foo sum if rep <=3 & rep>2 , color(gs12) ///
|| area freq sum if rep <=3 & rep>2 ///
|| area foo sum if rep <=4 & rep>3 , color(gs12) ///
|| area freq sum if rep <=4 & rep>3 ///
|| area foo sum if rep <=5 & rep>4 , color(gs12) ///
|| area freq sum if rep <=5 & rep>4 ///
||, legend(off) xlabel(none) xtitle("") yscale(off)
Scott
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/