Summarise a Distribution Through Coloured Intervals

Implements the functionality of the 'fanplot' package as 'geoms' for 'ggplot2'. Designed for summarising MCMC samples from a posterior distribution, where a visualisation is desired for several values of a continuous covariate. Increasing posterior intervals of the sampled quantity are mapped to a continuous colour scale.

Jason Hilton 05 March, 2019


This package is a ggplot-based implementation of some of the functionality of the fanplot package by Guy Abel. Fanplot provides methods to visualise probability distributions by representing intervals of the distribution function with colours. Plotting samples from posterior distributions obtained through MCMC is a particular aim. A ggplot-based implementation is useful as it allows leverage of the power of ggplot2 features allowing, for example, facetting and easy theming.


Installation directly from CRAN should be possible shortly, once the package has been resubmitted and checked: install.packages("ggfan") Otherwise, the package can be installed directly from github using the devtools package: devtools::install_github("jasonhilton/ggfan").

Quick Start

The provided fake_df data gives and example of the type of data you might want to plot with ggfan: it consists of 1000 samples of an outcome variable of interest at each value of a covariate x. We can plot this simply using standard ggplot2 syntax and geom_fan. Convenient ggplot features such as themes, colour scales and facetting can also be used.

ggplot(fake_df, aes(x=x, y=y)) + geom_fan() + theme_minimal() + scale_fill_distiller(palette="Spectral")

Further Information

A full description of the functionality of ggfan is provided in the vignette, provided here.

A brief example of using ggfan to plot stan output is given in a second vignette here


ggfan 0.1.3

  • Ensures compatibility with updates of dplyr and tibble (thanks to Francois Romain for adding the relevant import for dplyr.)

ggfan 0.1.2

  • Ensures compatibility with ggplot and hopefully therefore 2.3.0.
  • Adding a default linetype to GeomIntervalPath prevented an error in the call to draw_key_path in the new version of ggplot2.
  • Fix documentation links to external packages

ggfan 0.1.1

  • Make rstan a strong dependency to avoid warnings when running vignette or on load of dataset if this package is not installed on test platform.

ggfan 0.1.0

Initial submission to CRAN

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.3 by Jason Hilton, a year ago

Report a bug at

Browse source code at

Authors: Jason Hilton [aut, cre]

Documentation:   PDF Manual  

GPL-2 | file LICENSE license

Imports ggplot2, colorspace, dplyr, stats, grid, rstan

Suggests testthat, knitr, rmarkdown, tidyr, magrittr, tibble

See at CRAN