I want to drew the two groups such as a1, a2 and b1, b2 of vertical lines in ggplot using the following r functions.
myline = data.frame(vv = c(a1 = 25, a2 = 28, b1 = 52, b2 = 53))
set.seed(100)
d = data.frame(y = c(rnorm(100,5,1), rnorm(100, 2,4)), x = 1:200)
ggplot(data = d) + geom_line(aes(x, y), color = "steelblue") +
geom_vline(data = myline, aes(xintercept=as.numeric(vv)), col= 'red', size = 0.8)
I am trying to separate the a and b groups in different colors. How can I do that? Thank you very much for your suggestions.
