I am trying to create a ridgeline plot-type figure that displays count data on the Y-axis over time on the X-axis for individual years, stacked atop each other in a ridgeline plot (joyplot) type format. However, R only seems capable of supporting density plots in this format, where the Y axis is the distribution of the count data by frequency.
week <- c(rep(1:52,3)) # Simulated data
year <- c(rep(2012,52),rep(2013,52),rep(2014,52))
x1 <- rnbinom(52, 10, .5)
x2 <- rnbinom(52, 10, .5)
x3 <-rnbinom(52, 10, .5)
x <- c(x1,x2,x3)
df <- as.data.frame(cbind(year,week,x))
df %>% ggplot(aes(x=x,y=year)) +
geom_density_ridges(aes(fill=year,group=year))
# This shows the density of 'x' for each year
# whereas I would like to show the actual
# values of 'x' by week for each year
Is there a way to specify the X axis as 'week', the Y axis as a numeric value 'x', and each stacked ridgeline as 'year'?