How to use par() function In R Language

Here we will use par() function to divide frames into grids.

Syntax: par(mfrow, mar, mgp, las)

Parameters:

  • mfrow: A numeric vector of length 2, which sets the rows and column in which frame has to be divided.
  • mar: A numeric vector of length 4, which sets the margin sizes in the following order: bottom, left, top, and right.
  • mgp: A numeric vector of length 3, which sets the axis label locations relative to the edge of the inner plot window.
  • las: A numeric value indicating the orientation of the tick mark labels and any other text added to a plot after its initialization.

Here, by changing row and column values, we can draw graphs in them. For drawing side-by-side plots we will keep row as 1 and column as the no. of plots required.

R




# Define data-set columns
x1 <- c(31,13,25,31,16)
x2 <- c(12,23,43,12,22,45,32) 
  
# set the plotting area into a 1*2 array
par(mfrow = c(1, 2))    
  
# Draw the two line chart using above datasets
plot(x1, type="o", col="green")
plot(x2, type="o", col="blue")


Output:

Side by Side Line charts in R

In this article, we will discuss how to make side by side line chart in R Programming Language. 

Similar Reads

Method 1: Using par() function

Here we will use par() function to divide frames into grids....

Method 2: Using ggplot2

...

Contact Us