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: RE: Graphing Histograms and Overlaying A Vertical Line
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: RE: Graphing Histograms and Overlaying A Vertical Line
Date
Fri, 24 May 2013 19:05:21 +0100
This is a trick worth knowing, and I will give it a puff because Elan
is being modest about it.
-twoway function- draws functions that are y (variable on vertical
axis) = whatever, and whatever can be a constant. But here the problem
is to draw a function x (variable on horizontal axis) = whatever, and
whatever is a constant. The option -horizontal- is what flips it
around. It's documented, but like so much that is documented, it can
easily be overlooked.
Thanks for the nice example.
Nick
[email protected]
On 24 May 2013 18:48, Cohen, Elan <[email protected]> wrote:
> I see now. From http://www.stata-journal.com/sjpdf.html?articlenum=gr0014, the following should work:
>
> sysuse auto
> twoway__histogram_gen mpg, percent gen(h x)
> su h, meanonly
> loc max = 1.1*r(max)
> qui su mpg, d
> loc mean = r(mean)
> loc med = r(p50)
> tw hist mpg, percent || function y=`mean', hor ra(0 `max') || function y=`med', hor ra(0 `max')
>
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/