Tim
Tim

Reputation: 99408

"Error in plot.new() : figure margins too large" in R, is it because too many plots in one figure?

I would like to put about 80 plots in a figure, and about 160 plots in a figure. I run the following commands in R terminal:

> par(mfrow=c(10,8)); gelman.plot(output,auto.layout=F,autoburnin=F)
Error in plot.new() : figure margins too large
> dev.off()
null device 
          1 
> par(mfrow=c(10,16)); plot(output,auto.layout=F)
Error in plot.new() : figure margins too large

Should I change the mar or mai options in par()? But what values do you suggest me to do that?

What if I would like to save each figure into a pdf file?

> pdf('gelman.pdf')
> par(mfrow=c(10,8)); gelman.plot(output,auto.layout=F,autoburnin=F)
Error in plot.new() : figure margins too large
> dev.off()

How should I set up then? Thanks!

Upvotes: 2

Views: 10386

Answers (1)

koekenbakker
koekenbakker

Reputation: 3604

If you want many plots on a single device, you want to have sufficient width and height or narrow margins around each plot:

pdf(file='plot.pdf', width=10, height=10)
par(mfrow=c(10,10), mar=c(1,1,1,1))
for(i in 1:100){plot(rnorm(i))}
dev.off()

Default for mar=c(5,4,4,2)+0.1. Really, ?par is your friend.

Upvotes: 2

Related Questions