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

st: RE: Re: Re: Displaying mean in boxplot

From   "Nick Cox" <>
To   <>
Subject   st: RE: Re: Re: Displaying mean in boxplot
Date   Sun, 12 Oct 2008 17:12:17 +0100

One way to do this through marker symbols, as requested, is through
-stripplot- from SSC. 

sysuse auto, clear

egen mean = mean(mpg), by(foreign)

stripplot mpg, over(foreign) box stack centre height(0.2) ms(sh)
addplot(scatter foreign mean, ms(Dh) msize(*3)) 

With more work, you can come arbitrarily close to more conventional
forms of the box plot. 


Martin Weiss

Admittedly, my earlier solution did not give you the dot you were
for, but a reference line. If you have Stata 10, fire up the graph
afterwards, use the -add marker- tool and place the marker onto the 
reference line. Then highlight the reference line and kill it...
If -gr box- were part of the -twoway- family of graphs, one could
overlaying it with a -scatteri- to get the mean onto the graph more
than this...

Martin Weiss

> **********
> sysuse auto, clear
> su price, mean
> graph box price, box(1, fcolor(none)) yline(`r(mean)')
> **********

Aca N.T.

>> Does anyone know how to put mean (preferably marked as dot) within
>> box using -gr box-?

*   For searches and help try:

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