← Back to R Course | Chapter 10: Data Visualization | Lesson 6 of 7

par() Settings

par changes the settings of your drawing area, like choosing the paper size and pen style before you draw. You can, for example, place several plots on one page.

In this page:

  1. par() Settings
Syntax
r
old_par <- par(mfrow = c(rows, cols))
# draw plots here
par(old_par)

par() Settings

par() sets or queries global graphical parameters that affect subsequent plots, such as mfrow = c(rows, cols) to arrange multiple plots in a grid, or mar to adjust margins.

It's how you customize the overall plotting layout beyond a single plot() call's own arguments. Settings made with par() persist for the rest of the session unless reset.

Note: par(mfrow = c(2, 2)) arranges the next four plots into a 2x2 grid in the same plotting window.

Example: par() Settings

markup
cat("par(mfrow = c(2, 2)) would arrange the next 4 plots into a 2x2 grid\n")
cat("par(mar = c(4, 4, 2, 1)) would adjust the plot margins (bottom, left, top, right)\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
Common Mistakes
  1. Changing par(mfrow = c(2, 2)) and never resetting it, so later plots stay in the small grid.
  2. Setting par() before opening a new plot device, so the settings are lost.
  3. Making margins too small with mar, which cuts off axis labels and titles.
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.