Skip to content
Related Articles

Related Articles

How to Fix in R: error in : figure margins too large

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Mar, 2022

In this article, we will discuss how to fix the “figure margins too large” error in function of the R programming language.

The error that one may face in R is:

Error in : figure margins too large

The R compiler produces this error when the plot panel of Rstudio is small for the dimensions of the plot that we are trying to create.

When this error might occur:

Consider that want to create a plot using the plot() function in R. The syntax of this function is given below:


plot(start : end)


  • start: The starting point ( 1 for (x, y) = (1, 1) etc)
  • end: The ending point ( 5 for (x, y) = (5, 5) etc)

Return Type:

Draws dots in a sequence on both x and y axis



# Draw a plot


The R compiler produces the error (you can see the panel window is quite small at the right).

How to fix this error:

There are three ways to fix this error in R:

Method 1: Increasing the size of the panel

One way is to increase the panel size so that it can accommodate the plot across its dimensions:


# Draw a plot


Method  2: Using par() function

The par() function in R is used to set the margins of a plot. This function has the following syntax:




mfrow:  It represents a vector with row and column values for the grid

By default a plot has the following margins:

  • Top: 4.1 and Bottom: 5.1
  • Left: 4.1 and Right: 2.1

We need to explicitly set the margins of the plot as:


# Set plot margins
par(mar = c(1, 1, 1, 1))
# Create the plot
plot(1 : 40)


The plot was projected easily in the panel window because we reduced the margin to accommodate the created plot.

Method 3: Turn off the plotting device

If neither of the previous methods was able to fix the error then you can shut down the current plotting device by the following command:


# Turn off the device


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!