data("us_monthly")
head(us_monthly)
at_x <- seq.Date(from = as.Date("2000-01-01"),
to = as.Date("2020-01-01"),
by = "5 years")
at_y <- pretty(us_monthly$y)[c(2, 4, 6)]
plot(us_monthly$date, us_monthly$y,
col = "#1f77b4",
type = "l",
frame.plot = FALSE,
axes = FALSE,
panel.first = abline(h = at_y, col = "grey80"),
main = "US Total Natural Gas Consumption",
xlab = "Source: https://www.eia.gov/",
ylab = "Million Cubic Feet")
mtext(side =1, text = format(at_x, format = "%Y"), at = at_x,
col = "grey20", line = 1, cex = 0.8)
mtext(side =2, text = format(at_y, scientific = FALSE), at = at_y,
col = "grey20", line = 1, cex = 0.8)
Run the code above in your browser using DataLab