Get startedGet started for free

Control graphic parameters

In R, it is also possible to tailor the window layout using the par() function.

To set up a graphical window for multiple charts with nr rows and nc columns, assign the vector c(nr, nc) to the option mfrow. To adjust the size of the margins and characters in the text, set the appropriate decimal value to to the options mex and cex, respectively. Like plot(), each call to par() only implements the parameters in that particular call.

Look at this example:

> # Create 3x1 graphical window
> par(mfrow = c(3, 1))

> # Also reduce margin and character sizes by half
> par(mfrow = c(2, 1), mex = 0.5, cex = 0.5)

After this, you would make two consecutive calls to plot() to add the series in the order that you want them to appear.

It's time to practice! The dataset data is loaded in your workspace.

This exercise is part of the course

Visualizing Time Series Data in R

View Course

Exercise instructions

  • Create a 2x1 graphical window, then plot the first two series in data in that order, including the title for each of them
  • Reduce margin size to 60% and character size to 80% of their normal sizes and replot with same graphical window and titles

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot two charts on same graphical window




# Replot with reduced margin and character sizes


Edit and Run Code