CodePudding user response:
This way you could modify to achieve your desired plot:
library(tidyverse)
library(scales)
df1 <- df %>%
pivot_longer(
-date
) %>%
mutate(date = as.Date(date),
name = ifelse(name=="n_sym", "Onset of symptoms", "Date of reporting"))
ggplot(df1, aes(x=date, y=value, fill=name))
geom_col()
xlab("Onset of symptoms, alternatively date of reporting (2020)")
ylab("Number of reported cases")
scale_fill_manual(values = c("#ffc000", "#045aa0"))
scale_x_date(date_breaks = "1 day", labels = date_format("%d/%m"))
scale_y_continuous(expand = c(0, 0), limits = c(0, max(df1$value)),
breaks=seq(0,max(df1$value),100))
theme_classic()
theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust=1))
theme(legend.position="bottom")
guides(fill=guide_legend(title=""))
coord_fixed(ratio = .05)
theme(axis.title = element_text(size = 16))


