Figure 15-3: Point Marker Styles

Portfolio Categories: All Graphics and SGR Book Graphics.

Point Marker Styles in R Graphics

Point Marker Styles in R Graphics


# 15.2 Custom points ====================================================== 15.2

png(filename = "illustrations/fig-15-3-pch-values.png",
  units = "in",                        # Set measurements in inches
  res = 1200,                          # Set resolution at 1200dpi
  width = 6,                           # Width at 6 inches
  height = 6)                          # Height at 6 inches

par(mai = c(0, 0, 0, 0))               # No space around plot

plot(x = 0, y = 0,                     # Set up an empty plot
  xlim = c(0, 9), ylim = c(0, 14),     # Set x and y lengths
  type = "n",                          # Suppress points
  xaxt = "n", yaxt = "n",              # Suppress axis marks
  xlab = "", ylab = "")                # Suppress axis labels

points(x = c(rep(3, 13),rep(7, 13)),   # Add points in 2 cols (x = 3 & 7)
  y = c(c(13:1), c(13:1)),             # Increment y values for the 2 cols
  pch = c(0:25),                       # Run through 25 values for pch
  cex = 1.5)                           # Increase size to 1.5

text(x = c(rep(2, 13),rep(6, 13)),     # Add text labels also in 2 cols
  y = c(c(13:1), c(13:1)),             #  with incremented y values
  labels =                             # Label each point with 
    paste(as.character(c(0:25)),       #  the appropriate numeric
    " = "))                            #  value.

dev.off()                              # Close png device to output plot