Hello I'm plotting 6 graphs using "mfrow = c(2, 3)". In these plots, only graphs in the first column have titles for the y axis, and only the ones in the last row have titles for the x axis. I'd like all plots to be of the same size, and I'm trying to keep them as near each other as possible, but I'm having the following problem. If I make a single call to par(mar = ...), to leave room on the left and bottom for the axes titles, a lot of space will be wasted because not all graphs need titles; however, if I make one call of par(mar = ...) per plot, to have finer control of the margins, the first column and last row plots will be smaller than the rest, because the titles use up some of their space. I thought that setting large enough values for "oma" would do what I want, but it doesn't appear to work if "mar" is too small. To illustrate better what I'm trying to do: l +-----+ +-----+ +-----+ a | | | | | | b | | | | | | e | | | | | | l +-----+ +-----+ +-----+ l +-----+ +-----+ +-----+ a | | | | | | b | | | | | | e | | | | | | l +-----+ +-----+ +-----+ label label label where the margins between each plot should be narrow. Should I just plot the graphs without axis titles and then use text() to manually position them? Thanks in advance, Andre
Andre Nathan wrote:> Hello > > I'm plotting 6 graphs using "mfrow = c(2, 3)". In these plots, only > graphs in the first column have titles for the y axis, and only the ones > in the last row have titles for the x axis. > > I'd like all plots to be of the same size, and I'm trying to keep them > as near each other as possible, but I'm having the following problem. > > If I make a single call to par(mar = ...), to leave room on the left and > bottom for the axes titles, a lot of space will be wasted because not > all graphs need titles; however, if I make one call of par(mar = ...) > per plot, to have finer control of the margins, the first column and > last row plots will be smaller than the rest, because the titles use up > some of their space. > > I thought that setting large enough values for "oma" would do what I > want, but it doesn't appear to work if "mar" is too small. > > To illustrate better what I'm trying to do: > > l +-----+ +-----+ +-----+ > a | | | | | | > b | | | | | | > e | | | | | | > l +-----+ +-----+ +-----+ > > l +-----+ +-----+ +-----+ > a | | | | | | > b | | | | | | > e | | | | | | > l +-----+ +-----+ +-----+ > label label label > > where the margins between each plot should be narrow. > > Should I just plot the graphs without axis titles and then use text() to > manually position them?Can't you do it with lattice / grid? If not, example: par(mfrow = c(2,3), mar = c(0,0,0,0), oma = c(5,5,0,0), xpd=NA) plot(1, xaxt="n", xlab="", ylab="A") plot(1, xaxt="n", yaxt="n", xlab="", ylab="") plot(1, xaxt="n", yaxt="n", xlab="", ylab="") plot(1, xlab="I", ylab="B") plot(1, xlab="II", ylab="", yaxt="n") plot(1, xlab="III", ylab="", yaxt="n") Uwe Ligges> Thanks in advance, > Andre > > ______________________________________________ > 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.
Here is a response to almost exactly the same question from a couple of weeks ago: http://finzi.psych.upenn.edu/R/Rhelp08/2009-April/196967.html -- 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 Andre Nathan > Sent: Tuesday, May 12, 2009 11:12 AM > To: r-help at r-project.org > Subject: [R] Multiple plot margins > > Hello > > I'm plotting 6 graphs using "mfrow = c(2, 3)". In these plots, only > graphs in the first column have titles for the y axis, and only the > ones > in the last row have titles for the x axis. > > I'd like all plots to be of the same size, and I'm trying to keep them > as near each other as possible, but I'm having the following problem. > > If I make a single call to par(mar = ...), to leave room on the left > and > bottom for the axes titles, a lot of space will be wasted because not > all graphs need titles; however, if I make one call of par(mar = ...) > per plot, to have finer control of the margins, the first column and > last row plots will be smaller than the rest, because the titles use up > some of their space. > > I thought that setting large enough values for "oma" would do what I > want, but it doesn't appear to work if "mar" is too small. > > To illustrate better what I'm trying to do: > > l +-----+ +-----+ +-----+ > a | | | | | | > b | | | | | | > e | | | | | | > l +-----+ +-----+ +-----+ > > l +-----+ +-----+ +-----+ > a | | | | | | > b | | | | | | > e | | | | | | > l +-----+ +-----+ +-----+ > label label label > > where the margins between each plot should be narrow. > > Should I just plot the graphs without axis titles and then use text() > to > manually position them? > > Thanks in advance, > Andre > > ______________________________________________ > 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.