I have this kind of df :
data.frame(
stringsAsFactors = FALSE,
sampling_date_time = c("2021-10-12 07:48:43",
"2021-10-12 08:05:23","2021-10-12 08:22:03",
"2021-10-12 08:38:43","2021-10-12 08:55:23","2021-10-12 09:12:03"),
sunrise_date_time = c("2021-10-12 12:35:38",
"2021-10-12 12:36:07","2021-10-12 12:36:35",
"2021-10-12 12:37:05","2021-10-12 12:37:33","2021-10-12 12:38:05"),
sunset_date_time = c("2021-10-12 21:11:54",
"2021-10-12 21:11:26","2021-10-12 21:10:55",
"2021-10-12 21:10:25","2021-10-12 21:09:54","2021-10-12 21:09:25"),
period = c("night", "night", "night", "night", "night", "night"),
depth= c(236.660054398857,
263.628220939748,248.269863472482,143.411453432879,
118.336918769495,184.596392521635),
Value= c(3.81517529411765,
4.09484308571429,3.06502731428571,2.76729708571429,
2.65774266666667,2.72782291891892)
)
I did this plot and what I would like it's to have colored band (background) depending of the periode (day or night).
Like have a grey band for night and nothing for the day, something like that
data.frame %>%
ggplot(aes(sampling_date_time, depth)) +
geom_point(aes(colour = Value)) +
scale_colour_gradientn(colours = c("yellow","red")) +
scale_y_reverse()
axis.POSIXct(side=1, at=cut(data.frame$sampling_date_time, "days"), format="%m/%d")
Thanks !