# 15.2a Connectors ======================================================= 15.2a
png(filename = "illustrations/fig-15-5-point connectors.png",
units = "in", # Set measurements in inches
res = 1200, # Set resolution at 1200dpi
width = 6, # Width at 6 inches
height = 4) # Height at 6 inches
layout(matrix(c(1:12), # Setup a layout matrix
ncol = 4, # with 4 columns & 3 rows
byrow = T), # to fill by row.
heights = c(.45, .45, .1), # Relative heights
widths = c(.05, .3, .3, .3)) # Relative widths
layout.show(12) # Show the layout
par(mai = c(.1, .1, .5, .1)) # Set margins
plot.new() # Skip the first grid location
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "p", # Set connectors to just points
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
xaxt = "n", # Turn off x axis
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 'p'") # Add main title
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "l", # Set connectors to just lines
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
xaxt = "n", yaxt = "n", # Turn off axes
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 'l'") # Add main title
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "b", # Set connectors to both lines & points
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
xaxt = "n", yaxt = "n", # Turn off axes
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 'b'") # Add main title
plot.new() # Skip the 5th layout space
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "s", # Set connectors to stair steps
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 's'") # Add main title
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "h", # Set to histogram-style vertical lines
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
yaxt = "n", # Turn off y axis
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 'h'") # Add main title
plot(x = c(1:4), y = c(2, 4, 3, 4), # Plot some x & y values
type = "n", # Turn off points
xlim = c(0, 5), ylim = c(0, 5), # Set range of plot
yaxt = "n", # Turn off y axis
xlab = NA, ylab = NA, # Turn off axis labels
main = "type = 'n'") # Add main title
dev.off() # Close png device to output plot
Figure 15-5: Point Connector Styles
Portfolio Categories: All Graphics and SGR Book Graphics.