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:
Syntax
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
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")
Login to try C/C++/Java/PHP code in the editor
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
- Changing
par(mfrow = c(2, 2))and never resetting it, so later plots stay in the small grid. - Setting
par()before opening a new plot device, so the settings are lost. - 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: