Hi, All, I am trying to use R to make the following type of boxplot while I couldn't find a way to do it. My dataset looks like X1 Y1 X2 Y2.... SPLIT. The split highlights my experiment details and both x and y are continuous numerical values. I need to plot y vs. x with split as legend and boxplot has to be used for all splits. May I ask how to get it? Currently available boxplot only applies on the case that X axis is character. Thanks Qintao [[alternative HTML version deleted]]
Please supply some sample data and preferably the code that you have used so far. To supply data the best way is probably to use the dput() function. If your data is 'mydata' simply do : dput(mydata) and paste the results into your email John Kane Kingston ON Canada> -----Original Message----- > From: qintao.zhang at gmail.com > Sent: Sat, 8 Sep 2012 22:14:26 +0800 > To: r-help at r-project.org > Subject: [R] method or package to make special boxplot > > Hi, All, > > I am trying to use R to make the following type of boxplot while I > couldn't > find a way to do it. > > My dataset looks like X1 Y1 X2 Y2.... SPLIT. The split highlights my > experiment details and both x and y are continuous numerical values. I > need to plot y vs. x with split as legend and boxplot has to be used for > all splits. May I ask how to get it? Currently available boxplot only > applies on the case that X axis is character. > > Thanks > > Qintao > > [[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.____________________________________________________________ FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
On Sep 8, 2012, at 7:14 AM, Zhang Qintao wrote:> Hi, All, > > I am trying to use R to make the following type of boxplot while I couldn't > find a way to do it. > > My dataset looks like X1 Y1 X2 Y2.... SPLIT. The split highlights my > experiment details and both x and y are continuous numerical values. I > need to plot y vs. x with split as legend and boxplot has to be used for > all splits. May I ask how to get it? Currently available boxplot only > applies on the case that X axis is character.Boxplots do _not_ have continuous "X" axes. You will need to explain in greater detail what goal you are seeking. Perhaps something like a bagplot? http://gallery.r-enthusiasts.com/RGraphGallery.php?graph=112 -- David Winsemius, MD Alameda, CA, USA
The symbols function allows you to place boxplot symbols at specified x,y coordinates. Would that do what you want? On Sat, Sep 8, 2012 at 8:14 AM, Zhang Qintao <qintao.zhang at gmail.com> wrote:> Hi, All, > > I am trying to use R to make the following type of boxplot while I couldn't > find a way to do it. > > My dataset looks like X1 Y1 X2 Y2.... SPLIT. The split highlights my > experiment details and both x and y are continuous numerical values. I > need to plot y vs. x with split as legend and boxplot has to be used for > all splits. May I ask how to get it? Currently available boxplot only > applies on the case that X axis is character. > > Thanks > > Qintao > > [[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.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com
On 09/09/2012 12:14 AM, Zhang Qintao wrote:> Hi, All, > > I am trying to use R to make the following type of boxplot while I couldn't > find a way to do it. > > My dataset looks like X1 Y1 X2 Y2.... SPLIT. The split highlights my > experiment details and both x and y are continuous numerical values. I > need to plot y vs. x with split as legend and boxplot has to be used for > all splits. May I ask how to get it? Currently available boxplot only > applies on the case that X axis is character. >Hi Qintao, Do you want a sort of 2D boxplot? The example below gives a rough idea as to what it would look like, with boxplots for your Xs and Ys centered at their medians and an abcissa with the labels for your splits. Needs a bit of work to turn this into a function, so let me know if it does what you want. Jim x1<-rnorm(10) y1<-rnorm(10) y2<-rnorm(10) x2<-rnorm(10) x1sum<-boxplot(x1) y1sum<-boxplot(y1) offset=4 x2sum<-boxplot(x2,at=median(y2)+offset,add=TRUE) y2sum<-boxplot(y2+offset) bxp(x1sum,at=median(y1),xlim=c(y1sum$stats[1],y2sum$stats[5]), ylim=c(min(c(x1sum$stats[1],x2sum$stats[1])), max(c(x1sum$stats[5],x2sum$stats[5]))),axes=FALSE) bxp(y1sum,at=median(x1),add=TRUE,horizontal=TRUE,axes=FALSE) bxp(x2sum,at=median(y2+offset),add=TRUE,axes=FALSE) bxp(y2sum,at=median(x2),horizontal=TRUE,add=TRUE,axes=FALSE) box() axis(2) axis(1,at=c(median(y1),median(y2)+offset),labels=c("Split1","Split2"))