[R] Help

David L Carlson dcarlson at tamu.edu
Fri Jun 29 17:05:53 CEST 2012


Here are two possibilities depending on what you mean by "on top" of one
another:

> A <- matrix(rnorm(1000), ncol=10)
> B <- matrix(rnorm(1000), ncol=10)
> C <- matrix(rnorm(1000), ncol=10)
> oldpar <- par(mfrow=c(3,1), mar=c(3, 3, 2, 2))
> boxplot(A)
> boxplot(B)
> boxplot(C)
> par(oldpar)

Or really "on top" using color and changing the size of the boxes to make
them visible.

> boxplot(A)
> boxplot(B, border="red", boxwex=.7, add=TRUE)
> boxplot(C, border="blue", boxwex=.6, add=TRUE)

----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Petr PIKAL
> Sent: Friday, June 29, 2012 3:30 AM
> To: li li
> Cc: r-help
> Subject: Re: [R] Help
> 
> Hi
> 
> It seems to me that it can be done by ggplot2 package. However I do not
> understand what is three boxplots one on top of another? How could you
> see
> the bottom boxplot when it is twice overplotted?
> 
> library(ggplot2)
> p <- ggplot(mtcars, aes(factor(cyl), mpg))
> p + geom_boxplot(aes(fill = factor(vs)))
> 
> Regards
> Petr
> 
> 
> >
> > Dear all,
> >   I need some help on plotting multiple boxplots on one figure.
> >   I have three matrix A, B and C. Each of them is a 1000 by 10
> matrix.
> > The 10 columns of all three matrix correspond to the
> > 10 values of the same parameter, say k=1, ..., 10.
> >   I want to make a plot where x axis represents different values of
> k.
> > For each k value, I want to plot three boxplots, one on top of
> another.
> > For example, for k=1, I want to draw three boxplot based on the first
> > column of A, B and C respectively. Similarly, I do the same for the
> rest
> of
> > k values.
> >   Can some one give me some hint on this?
> >   Thank you so much.
> >         Hannah
> >
> >    [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list