Dear List, I'd really appreciate tip's or code demonstrating how i can achieve some common axis labels integrated into a multiple plot. In my example (below), i'm trying to achieve: -a single "Results 1 (Int)" centered & btwn row 1 and row 2; -a single "Results 2 (Int)" centered & btwn row 2 and row 3; and, -a single "Results 3 (Int)" centered at the bottom, ie., below row 3. I played with mtext() and par(oma=... per this post- https://stat.ethz.ch/pipermail/r-help/2004-October/059453.html But have so far failed to achieve my goal. Can i succeed with something combined with the 'high level' plot() function? Or do i need to get specific with some low level commands (help!)? With big thanks in advance for any suggestions/examples. cheers, Karl #my example: dev.new() plot.new() par(mfrow=c(3,2)) #Graph 1: plot(rnorm(20), rnorm(20), xlab = "Results 1 (Int)", ylab = "Variable A", main = "Factor X") #Graph 2: plot(rnorm(20), rnorm(20), xlab = "Results 1 (Int)", ylab = "Variable A", main = "Factor Y") #Graph 3: plot(rnorm(20), rnorm(20), xlab = "Results 2 (Int)", ylab = "Variable B") #Graph 4: plot(rnorm(20), rnorm(20), xlab = "Results 2 (Int)", ylab = "Variable B") #Graph 5: plot(rnorm(20), rnorm(20), xlab = "Results 3 (Int)", ylab = "Variable C") #Graph 6: plot(rnorm(20), rnorm(20), xlab = "Results 3 (Int)", ylab = "Variable C") -- Karl Brand Department of Genetics Erasmus MC Dr Molewaterplein 50 3015 GE Rotterdam T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268
On 06/26/2010 11:20 PM, Karl Brand wrote:> Dear List, > > I'd really appreciate tip's or code demonstrating how i can achieve some > common axis labels integrated into a multiple plot. > > In my example (below), i'm trying to achieve: > > -a single "Results 1 (Int)" centered & btwn row 1 and row 2; > -a single "Results 2 (Int)" centered & btwn row 2 and row 3; and, > -a single "Results 3 (Int)" centered at the bottom, ie., below row 3. > > I played with mtext() and par(oma=... per this post- > > https://stat.ethz.ch/pipermail/r-help/2004-October/059453.html > > But have so far failed to achieve my goal. Can i succeed with something > combined with the 'high level' plot() function? Or do i need to get > specific with some low level commands (help!)? >Hi Karl, Your request prompted me to have a look at the getFigCtr function in the plotrix package. All I had to do was to add an argument to adjust the proportion of the figure region that was calculated, and it will do what you want, I think. The new function will be in the next version. getFigCtr<-function(pos=c(0.5,0.5)) { pars<-par(c("usr","mar","fin","pin")) pxspan<-diff(pars$usr[1:2]) fxspan<-pxspan*pars$fin[1]/pars$pin[1] figxctr<- pars$usr[1]-(fxspan-pxspan)*pars$mar[2]/(pars$mar[2]+pars$mar[4]) + fxspan*pos[1] pyspan<-diff(pars$usr[3:4]) fyspan<-pyspan*pars$fin[2]/pars$pin[2] figyctr<- pars$usr[1]-(fyspan-pyspan)*pars$mar[1]/(pars$mar[1]+pars$mar[3]) + fyspan*pos[2] return(c(figxctr,figyctr)) } #my example: dev.new() plot.new() library(plotrix) par(mfrow=c(3,2)) #Graph 1: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable A", main = "Factor X") #Graph 2: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable A", main = "Factor Y") mtext("Results 1 (Int)",1,at=getFigCtr(c(0,0))[1],line=3) #Graph 3: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable B") #Graph 4: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable B") mtext("Results 2 (Int)",1,at=getFigCtr(c(0,0))[1],line=3) #Graph 5: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable C") #Graph 6: plot(rnorm(20), rnorm(20), xlab = "", ylab = "Variable C") mtext("Results 3 (Int)",1,at=getFigCtr(c(0,0))[1],line=3) Jim
How about: #my example: dev.new() layout( rbind( c(1,2), c(7,7), c(3,4), c(8,8), c(5,6), c(9,9) ), heights=c(10,1,10,1,10,1) ) #Graph 1: plot(rnorm(20), rnorm(20), xlab = "Results 1 (Int)", ylab = "Variable A", main = "Factor X") #Graph 2: plot(rnorm(20), rnorm(20), xlab = "Results 1 (Int)", ylab = "Variable A", main = "Factor Y") #Graph 3: plot(rnorm(20), rnorm(20), xlab = "Results 2 (Int)", ylab = "Variable B") #Graph 4: plot(rnorm(20), rnorm(20), xlab = "Results 2 (Int)", ylab = "Variable B") #Graph 5: plot(rnorm(20), rnorm(20), xlab = "Results 3 (Int)", ylab = "Variable C") #Graph 6: plot(rnorm(20), rnorm(20), xlab = "Results 3 (Int)", ylab = "Variable C") par(mar=rep(0,4)) plot.new() text( .5, .5, "Results 1 (Int)", font=2, cex=1.5 ) plot.new() text( .5, .5, "Results 2 (Int)", font=2, cex=1.5 ) plot.new() text( .5, .5, "Results 3 (Int)", font=2, cex=1.5 ) -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org 801.408.8111> -----Original Message----- > From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- > project.org] On Behalf Of Karl Brand > Sent: Saturday, June 26, 2010 7:21 AM > To: r-help at r-project.org > Subject: [R] several common sub-axes within multiple plot area > > Dear List, > > I'd really appreciate tip's or code demonstrating how i can achieve > some > common axis labels integrated into a multiple plot. > > In my example (below), i'm trying to achieve: > > -a single "Results 1 (Int)" centered & btwn row 1 and row 2; > -a single "Results 2 (Int)" centered & btwn row 2 and row 3; and, > -a single "Results 3 (Int)" centered at the bottom, ie., below row 3. > > I played with mtext() and par(oma=... per this post- > > https://stat.ethz.ch/pipermail/r-help/2004-October/059453.html > > But have so far failed to achieve my goal. Can i succeed with something > combined with the 'high level' plot() function? Or do i need to get > specific with some low level commands (help!)? > > With big thanks in advance for any suggestions/examples. > > cheers, > > Karl > > #my example: > dev.new() > plot.new() > par(mfrow=c(3,2)) > #Graph 1: > plot(rnorm(20), rnorm(20), > xlab = "Results 1 (Int)", > ylab = "Variable A", > main = "Factor X") > #Graph 2: > plot(rnorm(20), rnorm(20), > xlab = "Results 1 (Int)", > ylab = "Variable A", > main = "Factor Y") > #Graph 3: > plot(rnorm(20), rnorm(20), > xlab = "Results 2 (Int)", > ylab = "Variable B") > #Graph 4: > plot(rnorm(20), rnorm(20), > xlab = "Results 2 (Int)", > ylab = "Variable B") > #Graph 5: > plot(rnorm(20), rnorm(20), > xlab = "Results 3 (Int)", > ylab = "Variable C") > #Graph 6: > plot(rnorm(20), rnorm(20), > xlab = "Results 3 (Int)", > ylab = "Variable C") > > > -- > Karl Brand > Department of Genetics > Erasmus MC > Dr Molewaterplein 50 > 3015 GE Rotterdam > T +31 (0)10 704 3457 |F +31 (0)10 704 4743 |M +31 (0)642 777 268 > > ______________________________________________ > 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.