Fairly new to R so please excuse the crude code! I have a population of marked insects which I follow monthly. The marking level (ppm) decays over time. I would like to show a monthly density plot using ggridges, where the first month (9) showing the background (non-marked) population appears together with every following month to show the difference in signal between the marked and unmarked populations. Not sure how to get that background density plot to show with every months' plot. This is what I've tried:
df2 <- df1 %>% filter(!is.na(ppm)) %>%
mutate(Month = factor(Month, levels=c(9,10,11,12,1,2,3,4,5,6,7,8))) %>%
filter(Month %in% c(7,6,5,3,11,10,9)) %>%
mutate(month2 = "9")
df1 %>% filter(!is.na(ppm)) %>%
mutate(Month = factor(Month, levels=c(9,10,11,12,1,2,3,4,5,6,7,8))) %>%
filter(Month %in% c(7,6,5,3,11,10,9)) %>%
ggplot(., aes(x = ppm, y = Month, height = ..density.., fill=Month)) +
geom_density_ridges(scale = 2.8, stat = "density", alpha=0.8) +
scale_y_discrete(expand = c(0.01, 0)) +
scale_x_log10(limits=c(125, 190), breaks=seq(125, 190, 10)) +
scale_fill_manual(values=c("royalblue", "red3", "darkred", "firebrick3", "tomato2",
"indianred1", "mediumpurple3")) +
theme_ridges() + theme(legend.position = "none") +
geom_density_ridges(data=df2, aes(x = ppm, y = month2, height = ..density..), scale = 2.8,
stat = "density", alpha=0.5, fill='grey')