I have tried ribbon plot in R,but my output is not correct ,Can anyone tell whats the problem with my code,thanks in advance Output for ribbon plot
library(tidyr)
library(ggplot2)
library(dplyr)
library(reshape2)
library(tidyverse)
data = read.csv("Kolkata1.csv")
Dates = as.Date(data$X0)
data %>%
select(X0, Rain1,Rain2) %>%
filter(as.Date("2001-01-01") > as.Date(X0)) %>%
pivot_longer(!X0) %>%
group_by(X0) %>%
summarise(mean = mean(value, na.rm = T), sd = sd(value, na.rm= T),
high = mean(value, na.rm = T) + 0.2 * sd(value, na.rm= T),
low = mean(value, na.rm = T) - 0.2 * sd(value, na.rm= T)) %>%
ggplot() +
geom_point(aes(as.Date(X0), mean), size = 3) +
geom_line(aes(as.Date(X0), mean), size = 1.1) +
geom_ribbon(aes(x = as.Date(X0), ymax = high, ymin = low),fill = "steelblue2", alpha = 1)+
theme_bw()