I am interested in how this was done. Can this be done with ggplot? (I am interested in this kind of graph sorry. I should have been more clear)
What about that second line? the one shaded
library(ggplot2)
DF <- data.frame(Date = seq.Date(from = as.Date("2020-01-01"),
to = as.Date("2020-05-01"), by = 1),
Value = seq(1:122) + rnorm(122))
Projection = data.frame(Date = as.Date(c("2020-05-01", "2020-09-01")),
Value = c(DF[122, 2], 155))
rect_df <- data.frame(xmin=as.Date(c("2020-05-01")),
xmax=as.Date(c("2020-09-01")))
ggplot(mapping = aes(x = Date, y = Value)) +
geom_line(data = DF) +
geom_point(data = Projection) +
geom_line(data = Projection, linetype = 2) +
geom_rect(data=rect_df, aes(xmin=xmin, xmax=xmax, ymin=-Inf, ymax=Inf),
inherit.aes = FALSE, fill = "grey50", alpha = 0.5) +
scale_x_date(breaks = seq.Date(from = as.Date("2020-01-01"),
to = as.Date("2020-09-01"), by = "month"))
Created on 2020-04-26 by the reprex package (v0.3.0)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.