# 14.5 Simple axes and axis labels ======================================== 14.5
# 14.6 Building more complex axes ========================================= 14.6
# Turning axes off selectively (not in book).
default.par = par() # Save parameter settings
myV1 = c(1, 3, 4, 7, 9) # Set up some x values
myV2 = c(4, 6, 5, 3, 7) # Set up some y values
par(mfrow = c(2, 2)) # Create a 2x2 grid of plots
plot(myV1, myV2, type = "b", # Plot myV1 with myV2
main = "xaxt = 'n'", # Add main title
xaxt = "n") # Turn off x axis
plot(myV1, myV2, type = "b", # Plot myVq with myV2
main = "yaxt = 'n'", # Add main title
yaxt = "n") # Turn off y axis
plot(myV1, myV2, type = "b", # Plot myVq with myV2
main = "xaxt='n' & yaxt='n'", # Add main title
xaxt = "n", yaxt = "n") # Turn off x & y axes
plot(myV1, myV2, type = "b", # Plot myVq with myV2
main = "axes=FALSE", # Add main title
axes = FALSE) # Turn off both axes
# Axis Modifications I ---------------------------------------------------------
myV1 = c(1, 3, 4, 7, 9) # Set up some x values
myV2 = c(4, 6, 5, 3, 7) # Set up some y values
png(filename = "illustrations/fig-14-8-axes-BW.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
plot(myV1, myV2, # Plot myV1 and myV2
xaxt = "n", yaxt = "n", # Supress axes
xlim = c(0, 10)) # Set x range
axis(side = 1, # X axis
at = c(seq(0, 10, by = 2))) # tick marks every 2
axis(side = 1, # X axis minor tick marks
at = c(seq(1, 9, by = 2)), # Set on odd numbers
labels = NA, # No labels for minor tick marks
tcl = -.25) # Shorten minor tick marks
axis(side = 3, # Put another axis on top
at = c(0:10), # Ticks at 0-10
labels = LETTERS[1:11]) # Use alphabet labels
axis(side = 2, # Add Y axis
at = c(3:7), # Tick marks from 3-7 by 1
las = 1, # Rotate labels perpendicular to axis
lwd = 0, # Turn off axis line
lwd.ticks = 2, # Set tick width to 2
col.ticks = gray(.3)) # Set tick color
dev.off() # Ouput png file
Figure 14-8: Customized Axes
Portfolio Categories: All Graphics and SGR Book Graphics.