Interactive Statistical Graphics: Showing More By Showing Less

With interactive graphics one can start by showing the most important data features, then drill down to see details.

Vanderbilt University
School of Medicine
Department of Biostatistics


February 5, 2017

Version 4 of the R Hmisc package and version 5 of the R rms package interfaces with interactive plotly graphics, which is an interface to the D3 javascript graphics library. This allows various results of statistical analyses to be viewed interactively, with pre-programmed drill-down information. More examples will be added here. We start with a video showing a new way to display survival curves.

Note that plotly graphics are best used with RStudio Rmarkdown html notebooks, and are distributed to reviewers as self-contained (but somewhat large) html files. Printing is discouraged, but possible, using snapshots of the interactive graphics.

Concerning the second bullet point below, boxplots have a high ink:information ratio and hide bimodality and other data features. Many statisticians prefer to use dot plots and violin plots. I liked those methods for a while, then started to have trouble with the choice of a smoothing bandwidth in violin plots, and found that dot plots do not scale well to very large datasets, whereas spike histograms are useful for all sample sizes. Users of dot charts have to have a dot stand for more than one observation if N is large, and I found the process too arbitrary. For spike histograms I typically use 100 or 200 bins. When the number of distinct data values is below the specified number of bins, I just do a frequency tabulation for all distinct data values, rounding only when two of the values are very close to each other. A spike histogram approximately reduces to a rug plot when there are no ties in the data, and I very much like rug plots.

In the plotly graphic below, hover over areas of the histogram or over the mean or quantile symbols to show more information. Click components of the legend to turn off/on various computed quantities. By default the SD and Gini’s mean difference are not shown. Click on them to show these as horizontal lines just to the right of the category names.

with(support2, {
    units(meanbp) <- 'mmHg'
    histboxp(x=meanbp, group=dzgroup, sd=TRUE, bins=200)
} )