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]
Allan
From: "Michael Sorice" <[email protected]>
> 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.
***********************************************************************************
This email and any attachments are intended for the named recipient only. Its unauthorised use, distribution, disclosure, storage or copying is not permitted. If you have received it in error, please destroy all copies and notify the sender. In messages of a non-business nature, the views and opinions expressed are the author's own and do not necessarily reflect those of the organisation from which it is sent. All emails may be subject to monitoring.
***********************************************************************************
*
* 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/