Reputation: 1098
I would like to increase the size of my margins without altering the size of my plot region. What I'm doing is:
However, I always get the error:
Error in plot.new() : figure region too large
Can anyone help? There's obviously something I don't understand about how mai and fin interact.
Here is an example:
x=c(1,2)
y=c(2,4)
plot(x,y)
init_fin <- par("fin") #gives 7 7
init_mai <- par("mai") #gives 1.02 0.82 0.82 0.42
final_fin <- init_fin + 1 #now 8 8
par(mai=c(2.02,1.82,0.82,0.42), fin=final_fin)
plot(x,y)
ERROR:
Error in plot.new() : figure region too large
Upvotes: 0
Views: 11176
Reputation: 345
Use
par(mai = c(bottom, left, top, right))
before the plot. It will create extra space around the plot area. Change values of bottom, left, top and right according to your taste.
Upvotes: 1
Reputation: 77116
this error depends on the device you're using, I see it all the time with Rstudio because the plot panel is quite small on my laptop screen, and R thinks there's not enough space to display the graphic. One option is to open a bigger device window explicitly, e.g.
dev.new(width=10, height=10)
just before your last plot.
Upvotes: 4