[R-SIG-Mac] Error in plot.new() : figure margins too large
simon.urbanek at r-project.org
Wed Jul 20 17:08:25 CEST 2011
On Jul 20, 2011, at 5:55 AM, Timothy Bates wrote:
> Dear Mac R users,
> Not sure if this is mac/quartz specific or not.
> With my default graph size (about 3*3 inches), this code:
> layout(matrix(c(1, 2, 3, 3), 2, byrow = TRUE))
> plot(1:10); plot(11:20); plot(21:40)
> Gives the error "Error in plot.new() : figure margins too large”:
> If I expand the quartz window, run the code (error free), then reduce the window (generating an in window “margins" error message), then expand again: it redraws itself just fine.
> Question: Why doesn’t the code execute the same way when the window is initially too small? (i.e., draw into a window minimally big enough to allow the scaled graph to be rendered, then try rendering in the desired window, keeping the plot code intact and making an in-window error if necessary)?
The error comes from R, not Quartz. There is a big difference between a redraw and rerun: when you resize R just re-plays the display list, it doesn't create any new objects. When you rerun you are creating new graphics objects and R refuses to do so if your plot window is to small. This makes sense, because redraw doesn't change the layout according to the window dimensions while rerun does. That's why typically it's a bad idea to draw a plot and then resize the window without rerunning the code since the result will look different (worse).
More information about the R-SIG-Mac