I have a data set that I want to plot with a line graph. I have two "sets" of dates from 2006-2008 and then from 2015-2019. Ggplot keeps adding a line between these two points from 08-15 because technically there aren't any data gaps, it just spans over the two time periods. I don't want a line drawn between these two periods. How do I do this? I've tried adding a fake date between these two periods to trick R into adding a line break.
library(lubridate) # for working with dates
library(ggplot2) # for creating graphs
library(scales) # to access breaks/formatting functions
library(gridExtra) # for arranging plots
# Create Dataset
attach(TP)
df=data.frame(Site,Date,TP)
df %>% na.omit()
df$Date= as.Date(df$Date)
df$Site = factor(df$Site, levels = c("Site 1", "Site 2", "Site 3", "Site 4", "Site 5"))
ggplot(df, aes(x=Date, y=TP, group=Site)) +
geom_line(aes(color=Site)) +
scale_y_continuous( limits = c(0, 0.5))+
theme_classic() +
labs(x="", y=(expression(TP~ (mg-P~L^{-1})))) +
scale_x_date(limits = as.Date(c("2006-01-01","2019-12-30")),
labels = date_format("%Y"))