[R] Multiple figures margin problem

Greg Snow Greg.Snow at imail.org
Fri Feb 12 23:12:50 CET 2010


You do want outer margins, that is where the axis labels and tick marks will go for the plots that you want.

Try: par(mar=c(0,0,0,0), oma=c(5,4,1,1)+0.1)

Then do your plots to see if that is what you want.

-- 
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 mnstn
> Sent: Friday, February 12, 2010 2:49 PM
> To: r-help at r-project.org
> Subject: [R] Multiple figures margin problem
> 
> 
> Hello All,
> I am trying to make a figure with 3x2 plots in it. Let us name the
> plots as
> such:
> 
> 1 2
> 3 4
> 5 6
> 
> I begin my script with:
> par(mfcol=c(3,2))
> par(oma=c(0,0,0,0)) --> This is for a postscript figure so I really
> don't
> need the outer margins.
> d=5
> par(mar=c(d,d,d,d))  --> This applies to all the 6 plots.
> 
> Now if d=0, plots 1-2,3-4 and 5-6 will have no gap between them and 1-
> 3-5
> and 2-4-6 will not have any spacing either. This is how I want it. But
> I
> also want y axis points and y label for 1, 3 and 5 and x axis points
> and
> labels for 5 and 6. With d=0, there is no space left for these labels.
> With
> d=5 (for ex.) I can have the labels but it also introduces a gap of 'd'
> text
> lines between the plots. I have tried:
> 
> par(mar=c(0,d,0,0))
> plot 1
> par(mar=c(0,d,0,0))
> plot 3
> par(mar=c(d,d,0,0))
> plot 5
> par(mar=c(0,0,0,0))
> plot 2
> par(mar=c(0,0,0,0))
> plot 4
> par(mar=c(d,0,0,0))
> plot 6
> 
> But in this approach, the plots are all not of the same size because of
> differences in margins and I want all the plots to be square and look
> similar when printed. Do have any comments or suggestions on how to go
> about
> doing it?
> Thanks,
> MoonStone
> --
> View this message in context: http://n4.nabble.com/Multiple-figures-
> margin-problem-tp1490455p1490455.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> 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