Figure 13-6: Multiple Plot Layout

Portfolio Categories: All Graphics and SGR Book Graphics.

Multiple Plot Placement with R Graphics

Placing Multiple Plots Using R Graphics


# 13.6 Multiple plots ===================================================== 13.6
                     
png(filename = "illustrations/fig-13-6-mfrow.png",
  units = "in",                        # Set measurements in inches
  res = 1200,                          # Set resolution at 1200dpi
  width = 6,                           # Width at 6 inches
  height = 4)                          # Height at 4 inches

# mfrow approach
par(mfrow = c(1, 2))                   # Set mfrow for 1 row 2 columns
plot.new()                             # New plot
box("plot")                            # Draw box around plot area
box("fig")                             # Figure area box
text(x = .5, y = .5,                   # Put text in middle of plot
  labels = "This is plot 1",           #   identifying plot 1
  cex = 1.5)                           # Set font size

plot.new()                             # New plot
box("plot")                            # Draw box around plot area
box("fig")                             # Figure area box
text(x = .5, y = .5,                   # Put text in middle of plot
  labels = "This is plot 2",           #   identifying plot 2
  cex = 1.5)                           # Set font size

dev.off()                              # Output png file