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.