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 at the end of May, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Graphing Histograms and Overlaying A Vertical Line

From   "Dimitriy V. Masterov" <>
To   Statalist <>
Subject   Re: st: Graphing Histograms and Overlaying A Vertical Line
Date   Fri, 24 May 2013 13:33:44 -0700


Try something like this with xline():

sysuse auto, clear
sum price, detail
tw (hist price) (scatteri 0 `r(mean)' (0) "Avg." 0 `r(p50)' (0)
"Med.", ms(none) mlabsize(small)), xline(`r(mean)' `r(p50)')

You can remove the scatteri part if you don't want the lines labeled.

On Fri, May 24, 2013 at 7:21 AM, Erika Kociolek <> wrote:
> I am attempting to graph a histogram, overlaying vertical lines
> showing the mean and median. I know that the xline option won't get me
> what I want, so I went the twoway route. What I'm trying to figure out
> is how to get the range for "function" to match what's used for twoway
> histogram.
> summarize height
> twoway histogram height, percent || function y=`r(mean)', range(? ?)
> Any thoughts?
> Thanks!
> Erika
> *
> *   For searches and help try:
> *
> *
> *
*   For searches and help try:

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