# What are good ways of plotting distributions over time using R?

I have ~400 individuals and >10k timepoints each (simulation results) I would like to be able to monitor as they change over the course of time. Plotting all individuals is too messy, plotting mean +-sd, min/max, or quantiles is too little information for my taste. I am wondering what other people have come up with to visualize this type of data. If there were fewer data points I would use beanplots for each timepoint, but that would not work for so many timepoints.

• Are you looking to examine repeated measures (distribution of values within person level clusters) or panel results (functions of response variable within person over time) or are you just examining outcomes as a function of time? Bean plots (or violin plots) ignore clustering, but can be used to visualize observations that are discrete in time. Have you considered popular smoothers like LOESS or smoothing splines? Jan 29 '14 at 20:17
• @AdamO I just want to see distribution of outcomes over time. I am interested in how the distribution of an individual level statistic ("activity-level") changes as a way of watching a network of individuals. Each of the individuals interacts with a subset of the others, this also changes over time. Jan 29 '14 at 20:59
• Smoothers are capable of doing that. It's not a spaghetti plot which shows individual stats, but you can visualize an averaged trend over time. Jan 29 '14 at 21:27
• @AdamO I don't understand the suggestion of smoothing since I can simply plot the average at each timestep to see that. Jan 29 '14 at 21:43
• @Glen_b I would just calculate quantiles at each timepoint and make a timeseries out of those rather than use boxplots, I expect to see complex distributions though. Jan 29 '14 at 23:48

I would either use a smoother, such as:

geom_smooth(method='loess')


or I would subsample your data and plot only every 5 individuals, and every 10 time steps (for example).

library(ggplot2)
# Data looks like:
#   Subject   Timestep  Y
#   1         1         0.5
#   1         2         0.6
#   1         3         0.6
#   1         4         0.7
temp=subset(data, ((as.numeric(subject)%%5)==0) & ((as.numeric(Timestep)%%10)==0))
qplot(Timestep,Y,data=temp)


or both.

These are some great suggestions. My suggestion is to use half-violin plots as shown in http://biostat.mc.vanderbilt.edu/HmiscNew using the R Hmisc package summaryS function and lattice graphics.