Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: programming graphs in stata


From   "Scott Merryman" <[email protected]>
To   [email protected]
Subject   Re: st: programming graphs in stata
Date   Tue, 16 Oct 2007 18:36:26 -0500

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index