Time Series Plots Using ggplot2
Of course, the ggplot2 can also visualize time series. This section introduces the relevant ggplot2 syntax.
Plot multiple time series data
Set date axis limits
Key R function: scale_x_date()
# Base plot with date axis p <- ggplot(data = economics, aes(x = date, y = psavert)) + geom_line(color = "#00AFBB", size = 1) p # Set axis limits c(min, max) min <- as.Date("2002-1-1") max <- NA p + scale_x_date(limits = c(min, max))