Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: show distribution @ top of graph


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: show distribution @ top of graph
Date   Tue, 13 Dec 2005 09:38:36 -0500

Fred said
In older versions of Stata there used to be a way to display a distribution
as a second plot at the top of the graph. Is there still a way to do that
in Stata 9, perhaps as an overlay? I couldn't find information on this in
my searches.


[g] graph combine shows how to create one of the graphs on the Stata 9 poster: a scatterplot with histograms of the X and Y as borders. The enclosed does not do a perfect job, but with some tweaking...


sysuse lifeexp,clear
gen loggnp = log10(gnppc)
su loggnp,mean
local minx =`r(min)'-1
local maxx =`r(max)'+1
kdensity loggnp, saving(kd,replace) xsca(alt) xlabel(,grid) fysize (25) ///
xsca(range(`minx'/`maxx')) yline(0,lcolor(black)) nodraw
scatter lexp loggnp, saving(yx,replace) xsca(range(`minx'/`maxx')) xla (,grid) nodraw
graph combine kd.gph yx.gph, col(1) imargin(0 0 0 0) graphregion (margin(l=22 r=22)) ///
saving(fred,replace)



Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html


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