"Error in plot.new() : plot region too large" while plotting 4 maps(2*2) inside one layout/faced/grid using R

StackOverflow https://stackoverflow.com/questions/22124617

Question

I am new to R and trying to plot airline network graphs using Map in R. I am stuck at a point where I want to plot 4 different plots in a panel/ facet/grid. i am getting an error as follows :

Error in plot.new() : plot region too large

Sample Code till now :

   get( getOption( "device" ) )()


   par( mfrow = c( 2, 2 ) ) // 2 * 2 matrix intended 


   map("world", col="#191919", fill=TRUE, bg="#111111", lwd=0.05, xlim=xlim, ylim=ylim)

//sample map without any network lines ..

PS : This is not a duplicate post. I saw some posts with figure margins too large in R. But this is something different as per my understanding.

Was it helpful?

Solution

This is a problem linked to RStudio (see here). It occurs when the Plots pane area is smaller than the plot area.

Solutions:

  1. Enlarging the Plots pane (thanks to @Roman Luštrik for the suggestion). However it doesn't always work. Sometimes the plot area is still greater than the Plots pane area, even after increasing it.
  2. Using "raw R" as suggested by @Roman Luštrik (thanks again). It solves the problem completely since R adapts the plot size to the plotting window.
  3. Plotting to a file also solves the problem when using RStudio.

OTHER TIPS

run dev.off() before you plot your data

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top