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
"Nick Cox" <[email protected]>
To
<[email protected]>
Subject
RE: st: graph: how to draw 45 degree reference line
Date
Mon, 15 Mar 2010 16:05:32 -0000
Those paid by the reciprocal of the number of code lines written will be
interested in this shortened version.
. sysuse auto
. sum weight, meanonly
. local max = r(max)
. sum price, meanonly
. local max = max(`max', r(max))
. scatter weight price || scatteri 0 0 `max' `max', recast(line) name(a)
. scatter price weight || scatteri 0 0 `max' `max', recast(line) name(b)
It could be shortened further, but inelegance starts to escalate.
Nick
[email protected]
Friedrich Huebler
Nick's proposal can be modified to avoid having to specify the precise
coordinates of the line, an issue addressed by Dave earlier in this
thread. I assume that the line always start at the origin.
. sysuse auto
. sum weight, meanonly
. local max = r(max)
. sum price, meanonly
. if r(max) > `max' {
local max = r(max)
}
. scatter weight price || scatteri 0 0 `max' `max', recast(line) name(a)
. scatter price weight || scatteri 0 0 `max' `max', recast(line) name(b)
On Mon, Mar 15, 2010 at 8:06 AM, Nick Cox <[email protected]> wrote:
> [...]
>
> However, there is yet another way to do it:
>
> . sysuse auto
>
> . scatter weight price || scatteri 0 0 15000 15000, recast(line)
*
* 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/