Statalist


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

st: RE: Re: Boxplot w/ 2nd y-axis and mean overlay


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: Boxplot w/ 2nd y-axis and mean overlay
Date   Sun, 14 Jun 2009 18:16:01 +0100

Martin answered Michael's second question well, but my guess is that
Michael did not mean what he said. I guess he wants a mean for each
category, and extending Martin's solution to show several horizontal
lines is not especially attractive. 

With -stripplot- from SSC you can combine a dot plot (sensu -dotplot-),
display of boxes and display of means -- and indeed other possibilities.


This sequence omits the experimentation needed in practice to get a good
balance of elements. 

sysuse bplong, clear 
set scheme s1color 
egen mean = mean(bp), by(sex)
gen sex2 = sex - 0.1

stripplot bp, over(sex) vertical box(barw(0.1)) stack ///
boffset(-0.1) height(0.4) width(2) /// 
addplot(scatter mean sex2, ms(D) msize(*1.5)) 

Michael's first question about a second axis permits various answers,
mine being that what he wants is not possible with -graph box- and not a
good idea anyway. Create a second graph to show side by side with the
first. 

Nick 
[email protected] 

Martin Weiss

"Additionally, I'd like to add the mean to the boxplot.  Is there a way
to do so?"

***
sysuse bplong, clear
su bp, mean
graph box bp, over(sex) ///
yli(`r(mean)') yla(`r(mean)')
***

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.  Is there a way
to 
> do so?
>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index