-4

Is there a way to plot densities over a time series? I'm looking for something like this: a MS Paint drawing of what I want

merv
  • 67,214
  • 13
  • 180
  • 245

1 Answers1

0

Claus Wilke has some great examples of exactly this in the vignettes of the ggridges package. Here's a reproducible one illustrating how it's done:

library(ggridges)
library(ggplot2movies)

ggplot(movies[movies$year>1912,], aes(x = length, y = year, group = year)) +
  geom_density_ridges(scale = 10, size = 0.25, rel_min_height = 0.03) +
  theme_ridges() +
  scale_x_continuous(limits=c(1, 200), expand = c(0.01, 0)) +
  scale_y_reverse(breaks=c(2000, 1980, 1960, 1940, 1920, 1900), expand = c(0.01, 0))

Film Lengths by Year

enter image description here

merv
  • 67,214
  • 13
  • 180
  • 245