I have the plot below and I would like to add a vertical line at "11:20:33"
I was trying to to use: geom_vline(aes(xintercept = "11:20:33" ))
but that does not seem to work. Any ideas?
library(scales)
library(ggplot2)
time = as.POSIXct(c("2016-06-30 15:20:23 GMT","2016-06-30 15:20:25 GMT","2016-06-30 15:20:27 GMT","2016-06-30 15:20:29 GMT","2016-06-30 15:20:35 GMT"),tz = "GMT")
attr(time, "tzone") <- "America/New_York"
class(time)
value = c(10,NA,0, 5, 0)
category = c(0,0,0,0,0)
dat = data.frame(t = time, value = value, category = category)
dat
str(dat)
ggplot(dat, aes(x=t, y = value, group = 1 )) +
geom_point(aes (color = as.factor(category)) ) +geom_line() +
geom_vline(aes(xintercept = "11:20:33" )) +
scale_x_datetime(date_labels = "%H:%M:%S")+ theme(axis.text.x = element_text(angle = 90, hjust = 1, size = 7))