Figure 14-11: Default Date Axes

Portfolio Categories: All Graphics and SGR Book Graphics.

Default Date Axis

Default Date Axis


# 14.6b Axes and Dates =================================================== 14.6b

dFormat = "%m/%d/%Y"                   # Set up a date format
myDate = as.Date(c("10/12/1947",       # Set up a date variable
  "5/14/1969", "7/2/1998", "1/3/2004", #  with several dates
  "11/24/2012"), dFormat)              #  using the format above
myV2 = c(14, 32, 7, 19, 11)            # Another simple variable

# A simple default time plot ---------------------------------------------------

png(filename = "illustrations/fig-14-11-dates.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, .25, .25))

plot(myDate, myV2)                     # Basic plot with defaults

dev.off()                              # Output png file