Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: graph: how to draw 45 degree reference line
From
<[email protected]>
To
<[email protected]>
Subject
Re: st: graph: how to draw 45 degree reference line
Date
Mon, 15 Mar 2010 10:23:47 +0100
Hi Statalisters,
Friedhelm Huebler wrote:
-line price price- is easy but depending on the resolution of the
display the line will not appear entirely straight. The appearance
also depends on how the data are sorted. -function- with the option
n(2) yields a cleaner graph. The setting of the range can be
automated.
. sysuse auto, clear
. sum price, meanonly
. local xmin = r(min)
. local xmax = r(max)
. twoway (scatter weight price) (function y=x, range(`xmin' `xmax')
n(2)), aspect(1)
****
I think, - twoway lfit - is best in this case:
// Line from min to max:
. twoway scatter weight price || lfit price price, aspect(1) range(. .) n(2)
// Line from 0 to max:
. twoway scatter weight price || lfit price price, aspect(1) range(0 .) n(2)
The "range" option of - lfit - is more versatile.
Friedhelm Hueblers "n(2)" trick works with - lfit -
Regards
Stefan Gawrich
HLPUG
Dillenburg
Germany
*
* 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/