Description Usage Arguments Details Computed variables Examples
Visualise the distribution of continuous variables by dividing each variables into a fixed number of bins and returning the bin limits. In fan plots ('geom_fan') bins are grouped over all variables and colored after their distance from the center bin, which corresponds to the median. The center bin corresponds to the strongest shade of 'colorbase', while other bins get decreasing shades.
1 2 3 4 5 6 7 |
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
step |
the number of quantiles to use to compute bins |
colorbase |
the colors to use to draw the ribbon. defaults to RColorBrewer 'Oranges'.
See |
... |
Other arguments passed on to |
geom |
The geometric object to use display the data |
'stat_fan' is suitable only for continuous y data. Moreover, if you have less than '1/step' points you might need to adjust the 'step' parameter.
the lower limit of the quantile
the upper limit of the quantile
an identifier for the quantile
the fill colorto use in geom_fan
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # reformat dataset from short-wide to tall-skinny
EuStockMarkets_ts <- lapply(colnames(EuStockMarkets),function(id) {
data.frame(id=id,value=as.numeric(EuStockMarkets[,id]))
})
EuStockMarkets_ts <- do.call('rbind',EuStockMarkets_ts)
# plot the distribution of the different stock markets
ggplot(EuStockMarkets_ts,aes(x=id,y=value))+
geom_fan()
# Change the step
ggplot(EuStockMarkets_ts,aes(x=id,y=value))+
geom_fan(step=0.05)
# change the default color
ggplot(EuStockMarkets_ts,aes(x=id,y=value))+
geom_fan(colorbase='Greens')
# any valid RColorBrewer palette will work
ggplot(EuStockMarkets_ts,aes(x=id,y=value))+
geom_fan(colorbase='RdYlGn')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.