Figure 14-9: More Axis Effects

Portfolio Categories: All Graphics and SGR Book Graphics.

Demonstration of More Customized Axes

More Customized Axis Effects


# Axis positions and modifications II ------------------------------------------

png(filename = "illustrations/fig-14-9-more axes.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

par(mai = c(1, 1, .5, .25))

plot(myV1, myV2,                       # Plot myV1 and myV2
  xaxt = "n", yaxt = "n",              # Suppress axes
  xlim = c(0, 10),                     # Set x range
  xlab = NA)                           # Turn off X label  

axis(side = 1,                         # Set up new X axis
  at = c(seq(0, 10, by = 2)),          # Tick marks trom 0-10 by 2
  labels = c("Zero", "Two", "Four",    # Labels for tick marks
    "Six", "Eight", "Ten"),
  family = "serif",                    # Set font
  cex.axis = 1.5,                      # Increase font size by 50%
  las = 2,                             # Make labels perpendicular to axis
  line = 1)                            # Put axis 1 line into the margin

axis(side = 2,                         # Set up new Y axis
  at = c(3:7),                         # Set tick marks from 3-7 by 1
  font = 4,                            # Set font to bold italic
  lwd.ticks = 2,                       # Set major tick line width at 2
  pos = -.5)                           # Set axis at -.5 on X scale

axis(side = 2,                         # Overlay minor tick marks on Y axis
  at = c(3.5:6.5),                     # Put them on the .5 marks
  labels = NA,                         # No labels
  tcl = -.25,                          # Set length of tick marks
  pos = -.5)                           # Set position of axis (same as above)     

axis(side = 3,                         # Add another axis on top of plot
  at = c(seq(0, 10, by = 1.35)),       # Set another scale
  labels = c(seq(100, 170, by = 10)),  # Add labels
  padj = 1,                            # Adjust labels downward
  tcl = 1)                             # Put long tick marks into plot area

dev.off()                              # Output png file