Hi all, I'm trying to do multiple graphs in a window like this: ___ ___ ___ ylab |__| |__| |__| ___ ___ ___ ylab |__| |__| |__| ___ ___ ___ ylab |__| |__| |__| xl xl xl If I try to put the labels manually, some graphs become smaller than other and the output is really ugly. In the thread title I put the word "conditional" because I'm trying to do a function, and in that function I want to print ylabels if the plot positions is at first column of the graph matrix, and xlab if the position is at last row of matrix. How can i achive this two things? Thanks for your help -- CdeB
Hi, Have you considered using high-level plotting functions provided by the ggplot2 or lattice package? Here's a dummy example,> > x <- seq(0, 10, length=100) > y1 <- sin(x) > y2 <- cos(x) > y3 <- x^2/100 > y4 <- 1/x > > d <- data.frame(x, y1, y2, y3, y4) > > library(reshape) > dm <- melt(d, id="x") > > dm$type1 <- rep(LETTERS[1:2], each=2*length(x)) # dummy factors > dm$type2 <- rep(letters[1:2], each=length(x)) > > library(ggplot2) > p1 <- > qplot(x, value, data=dm, geom="line", facets=type1~type2) > > p1 # you can customise the appearance if the default doesn't please > you > > library(lattice) > > p2 <- > xyplot(value~x|type1*type2, data=dm, t="l") # here the strips are on > top of each other by default > > library(latticeExtra) > > useOuterStrips(p2) # this makes the layout more like you wantAlternatively, you can also use raw Grid commands and define your own layout where to place the different graphical objects, but it's more work. Hope this helps, baptiste On 26 Apr 2009, at 01:31, Christian Bustamante wrote:> Hi all, > I'm trying to do multiple graphs in a window like this: > > ___ ___ ___ > ylab |__| |__| |__| > ___ ___ ___ > ylab |__| |__| |__| > ___ ___ ___ > ylab |__| |__| |__| > xl xl xl > > If I try to put the labels manually, some graphs become smaller than > other and the output is really ugly. > In the thread title I put the word "conditional" because I'm trying to > do a function, and in that function I want to print ylabels if the > plot positions is at first column of the graph matrix, and xlab if the > position is at last row of matrix. > > How can i achive this two things? > > Thanks for your help > > -- > CdeB > > ______________________________________________ > 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._____________________________ Baptiste Augui? School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag
Here is one example that moves the axes to the outer margins, play with the different settings to see the effects: par(oma=c(3,3,3,3)+.1, mar=c(0,0,0,0)+0.1, mfrow=c(3,3)) for (i in 1:9) { plot( runif(10*i), runif(10*i), ann=FALSE, xlim=c(0,1), ylim=c(0,1), xaxt='n', yaxt='n' ) if( i %% 3 == 1 ) axis(2, outer=TRUE) if( (i-1) %/% 3 == 2 ) axis(1, outer=TRUE) } Hope this helps, -- 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 Christian Bustamante > Sent: Saturday, April 25, 2009 6:31 PM > To: r-help at r-project.org > Subject: [R] Conditional plot labels > > Hi all, > I'm trying to do multiple graphs in a window like this: > > ___ ___ ___ > ylab |__| |__| |__| > ___ ___ ___ > ylab |__| |__| |__| > ___ ___ ___ > ylab |__| |__| |__| > xl xl xl > > If I try to put the labels manually, some graphs become smaller than > other and the output is really ugly. > In the thread title I put the word "conditional" because I'm trying to > do a function, and in that function I want to print ylabels if the > plot positions is at first column of the graph matrix, and xlab if the > position is at last row of matrix. > > How can i achive this two things? > > Thanks for your help > > -- > CdeB > > ______________________________________________ > 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.