Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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
njcoxstata@gmail.com


On 24 May 2013 18:48, Cohen, Elan <cohened@upmc.edu> 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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index