You need to wrap the date in your geom_vline
into an as.Date
:
geom_vline(xintercept=as.Date("2020-10-13"), linetype="dashed", color = "red")
The full code (with some simulated data to reproduce your graph - please next time consider sharing your data with a short dput()
command):
df_total <- tibble(date = seq.Date(from = as.Date("2020-10-01"),as.Date("2020-10-24"), by = "day"),
neutral = rnorm(24),
positive = rnorm(24),
negative = rnorm(24))
df_total %>%
pivot_longer(-date, "sentiment", values_to = "count") %>%
ggplot(aes(x=date, y =count,group=sentiment)) +
geom_line(aes(color=sentiment,linetype=sentiment)) +
scale_color_manual(values=c("red","blue","springgreen4")) +
geom_vline(xintercept=as.Date("2020-10-13"), linetype="dashed", color = "red")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…