Statalist


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

st: RE: Re: Boxplot w/ 2nd y-axis and mean overlay (statalist-digest V4 #3456)


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: Boxplot w/ 2nd y-axis and mean overlay (statalist-digest V4 #3456)
Date   Mon, 15 Jun 2009 17:22:52 +0100

I don't know StataCorp's views on this, but I have some of my own. 

A request to add means to box plots is sufficiently common that
StataCorp may give in sooner or later, but what next? Means and
confidence intervals? The trade-off between giving customers what they
want and adding yet more complications to already complicated commands
is not easy. 

Allan didn't spot my deliberate silence on my -stripplot- and second
axes. As -stripplot is a wrapper for -twoway- it would support second
axes, whether to good or not-so-good ends. 

Beware of box plots and log scales for different reasons, spelled out at


http://www.stata.com/support/faqs/graphics/boxandlog.html

The essence of the matter is that box(log()) and log(box()) are not
necessarily identical. 

Nick 
n.j.cox@durham.ac.uk 

Allan Reese

Further to Nick Cox's replies, you can add category means to boxplots as
added text, but have to fiddle with the x positions since Stata treats
the category axis differently.
Eg,
sysuse auto
egen mmpg = mean(mpg), by(foreign)
tab mmpg   // to copy and round the values.
graph box mpg, over(for) text(19.8 21 "*") text(24.8 80 "*")

I don't think that's an adequate solution, and the question has been
raised several times on Statalist.  It would be good to have a "graph
twoway box" plot, so that boxes can be intelligently combined with, eg,
median smoothing lines. 
[Action StataCorp]

I too wanted a second axis on a boxplot last week and found it's not
allowed.  Nick's contemnation of second axes is valid when graphs are
superimposed despite having incompatible units, and I've seen examples
of Procrustean spin to create "correlations" that way.  Multiple scales
on a single graph obstruct relating particular points to the appropriate
scale.

But it is perfectly reasonable to have right and left axes with
different labelling and I cannot see why the software should deny
multiple axes at any position. One use would be to label one axis with
the log values and the other with natural numbers; my example would have
labelled one axis with the range for one group (or variable) and the
other axis with another range; you could make nested categories with the
major groupings labelled at the top and the minor ones at the bottom;
although Stata has always drawn axes outside the plotting area,
traditional graphs have axes through the origin which may be within the
plot.  I even tried the graph editor, thinking it would pick up the axis
as an object to copy. (Nah!)  
[Action StataCorp]

From: "Michael Sorice" <msorice@tamu.edu>

> I've created a boxplot summarizing three variables over 3 groups. The 
> command line looks like:  graph box A1 A2 B1, over(group)
> Variables A1 & A2 are on the same scale but B1 is on a larger scale.
> Is there a way to put B1 on a 2nd y-axis?  I'd like them all on one
plot 
> and readable.  I can only find a 2nd y-axis option for the "twoway" 
> command.
>
> Additionally, I'd like to add the mean to the boxplot.  

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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