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, 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 <>
To   "" <>
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.


On 24 May 2013 18:48, Cohen, Elan <> wrote:
> I see now.  From, 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:

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