# Best visualization for distributions at multiple time steps

I have a set of discrete observations at multiple time points (~40) all of which are at similar scales i.e., between 0 and 10, and have been trying to determine the best visualization to show the individual distributions in one plot, ideally without just plotting summary statistics via box-plots or something similar (although this may very well turn out to be the best option in the end). Is there any suggestions of plots suited to such visualizations, ideally in ggplot?

Other options I've thought of is a line-chart for the mean along with 95% percentiles at each time point and appears to be the best option at the moment. Below is some simulated data (the real dataset is much larger, and more varied in distribution).

df = data.frame(points = c(), time = c())

for (i in 1:40){
temp <- as.data.frame(cbind(sqrt(i)*sample(1:10, 10000, replace=T), rep(i,10000)))
names(temp) <- c('points','time')
df <- rbind(df, temp)
}

ggplot(df %>%
group_by(time) %>%
summarise(025%=quantile(points, probs=0.025),
0975%=quantile(points, probs=0.975),
avg=mean(points)), aes(x = time, y = avg)) +
geom_ribbon(aes(ymax = 0975%, ymin = 025%), fill = 'red',
alpha = 0.1, show.legend = FALSE) +
geom_line(size = 1, col = 'red') +
geom_point()


Any comments would be greatly appreciated.

• 40 histograms with 10 bins each might well work. Oct 7, 2019 at 16:38
• Thanks for the reply Nick, agreed that a histogram is a great way to plot the distribution. However I feel as though 40 histograms in a single plot would be much to cluttered... in the end it may prove to be the best option but hoping to hear some alternative suggestions. Oct 7, 2019 at 17:29
• I don't have your data, but it seems that you haven't even tried this suggestion. Oct 7, 2019 at 17:40

I like 2D kernel density plots, which are very similar to your plot. They differ in showing continuous variation, not just the means and confidence intervals. This is an example I found through google: The X-axis would be time in your case, of course.

• This works nicely for continuous data, but with only 11 discrete values available it's likely to fail.
– whuber
Oct 7, 2019 at 16:46
• @whuber Why do you think it is likely to fail? I would expect it to work fine, though the plot would be more blocky than the example here.
– mkt
Oct 7, 2019 at 16:51
• Nice suggestion, will definitely take a look at such plots. Oct 7, 2019 at 17:31
• That's exactly right. Not only that, but with many data of this form the effective range is much smaller than the nominal range. For instance, responses to happiness questionnaires tend to be in the 5-10 range, with the vast bulk between 6 and 9: just four separate values. Wouldn't all details of the distribution get lost in that "blockiness"? This seems to call for a different method of visualization, one designed to represent such discrete probabilities.
– whuber
Oct 7, 2019 at 18:24