Increase or Decrease margin Around Plot using par() function

In this method to increase or decrease the margin around the plot in the R Language, the user need to use the mar argument of the par() function. Here, the mar argument takes a vector with all the margin values in the following order: bottom, left, top, right as value. The default is mar = c(5.1, 4.1, 4.1, 2.1).

Syntax:

par( mar )

where,

  • mar: determines the margin vector in which margins are in the order: bottom, left, top, right

Example:

Under this example, we have added large left and top margins to a plot using the mar argument of par() function.

R




# Add margin using par() function
par( mar= c(1,15,15,1) )
 
# create plot
plot( 1:20 )


Output:

How to Use Par Function in R?

In this article, we will discuss how to use the par() function in the R Programming Language.

The par() function is used to set or query graphical parameters. We can divide the frame into the desired grid, add a margin to the plot or change the background color of the frame by using the par() function. We can use the par() function in R to create multiple plots at once. This helps us to create a figure arrangement with fine control.

Similar Reads

Method 1: Create Multiple plots in the same window using par() function

To create multiple plots in the same window in the R Language, we first divide the frame into the desired grid by using the mfrow argument of the par() function. Here, we can pass a vector containing a number of rows and columns for the grid as value to argument mfrow and this will divide our frame into a grid of that number of rows and columns....

Method 2: Increase or Decrease margin Around Plot using par() function

...

Method 3: Change axis and tick label size using par() function

In this method to increase or decrease the margin around the plot in the R Language, the user need to use the mar argument of the par() function. Here, the mar argument takes a vector with all the margin values in the following order: bottom, left, top, right as value. The default is mar = c(5.1, 4.1, 4.1, 2.1)....

Method 4: Change the background color of the window using par() function

...

Contact Us