Error in frame() : figure margins too large
I am trying to create a matrix of plots, but I want the upper left corner to be blank. So I'm using:
frame()
To which R responds:
Error in
frame()
: figure margins too large
I'm using the following two lines to create my layout:
plotIDs <- matrix(c(1:16), 4, 4, byrow = T);
layout(plotIDs, widths = c(0.5,1,1,1,1), heights = c(0.5,1,1,1,1));
and this gives me the following layout:
If I then issue frame()
I get th开发者_开发技巧e above error. What am I doing wrong? I don't see any way to specify a height or a width for the frame()
command (just an alias for plot.new()
)?
The message means that the margins in the figure are too large and do not leave enough space for the plot.
Try reducing the margin:
op <- par(mar = par("mar")/2)
plot.new() ## this is optional for this example
plot(1:10)
par(op) ## tidy up to restore the default par setting
You can start with frame() or plot.new(), or just plot into the first panel. Note you will need to consider what is an appropriate margin setting for each of your different panels, and fine-tune label sizes and so on.
For a totally blank panel, you might as well kill the margin completely:
op <- par(mar = rep(0, 4))
plot.new()
par(op)
You can leave panels blank using layout by having a 0 in the matrix, so if you use 0:15 instead of 1:16 then the 1st panel will be blank without you needing to skip. Of course you will neet to set margins and cex for the rest of the panels.
精彩评论