Description Usage Arguments Aesthetics See Also Examples
Fan Plots allow the distribution of a variable to be visualised by
representing sets of central probability intervals through colour.
For every value of x
, geom_fan
computes quantiles of y
and uses these to plot
intervals containing increasing proportions of the total density of y
.
Intervals are mapped to a continuous colour scale, so that changes in colour
represent intervals covering an increasing proportion of total density.
Quantiles can also be precomputed and mapped to the aesthetic quantile
.
This function is designed with the need to summarise MCMC posterior
distributions in mind, and implements the functionality of the fanplot
package in ggplot2
. Note that there should be enough observations of
y
at each x
to allow estimation of the specified quantiles.
1 2 3 
mapping 
Set of aesthetic mappings created by 
data 
The data to be displayed in this layer. There are three options: If A A 
stat 
Use to override the default use of 
position 
Position adjustment, either as a string, or the result of a call to a position adjustment function. 
show.legend 
logical. Should this layer be included in the legends?

inherit.aes 
If 
intervals 
specify the collection of intervals to be represented in the fan. 
... 
other arguments passed on to 
geom_fan
understands the following aesthetics (required aesthetics are in bold):
x
y
alpha
group
quantile
stat_summary
Summarises y at each value of x
stat_quantile
Uses quantile regression to predict quantiles
geom_interval
Plot intervals boundaries as lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17  # Basic use. The data frame must have multiple y values for each
# x
library(ggplot2)
ggplot(fake_df, aes(x=x,y=y)) +geom_fan()
# use precomputed quantiles  reducing storage requirements.
intervals = 1:19/20
fake_q < calc_quantiles(fake_df, intervals=intervals)
# intervals in geom_fan must be the same as used to compute quantiles.
ggplot(fake_q, aes(x=x,y=y, quantile=quantile)) +
geom_fan(intervals=intervals)
# change the colour scale
ggplot(fake_df, aes(x=x,y=y)) + geom_fan() + scale_fill_gradient(low="red", high="pink")

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.