geom_cloud: geom_cloud

Description Arguments Details Aesthetics Note Author(s) See Also Examples

Description

Draw a normal uncertainty cloud as a ribbon

Draws overlapping ribbons of the same identity to create a cloud of (Gaussian) uncertainty. Similar to an errorbar geom in use, but visually less distracting (sometimes).

Geom Proto

Arguments

steps

The integer number of steps, or equivalently, the number of overlapping ribbons. A larger number makes a smoother cloud at the possible expense of rendering time. Values larger than around 20 are typically not necessary.

max_alpha

The maximum alpha at the maximum density. The cloud will have alpha no greater than this value.

se_mult

The ‘multiplier’ of standard errors of the given ymin and ymax. If these are at one standard error, then let se_mult take the default value of 1.

Details

Assumes that ymin and ymax are plotted at a fixed number of standard errors away from y, then computes a Gaussian density with that standard deviation, plotting a cloud (based on geom_ribbon) with alpha proportional to the density. This appears as a vertical ‘cloud’ of uncertainty. In use, this geom should be comparable to geom_errorbar.

A sample output from geom_cloud:

Figure: geom\_cloud-1.png

Aesthetics

geom_cloud understands the following aesthetics (required aesthetics are in bold):

Only one of ymin and ymax is strictly required.

Note

This is a thin wrapper on the geom_ribbon geom.

Author(s)

Steven E. Pav shabbychef@gmail.com

See Also

geom_ribbon: The underlying geom

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
set.seed(2134)
nobs <- 200
mydat <- data.frame(grp=sample(c(0,1),nobs,replace=TRUE),
  colfac=sample(letters[1:2],nobs,replace=TRUE),
  rowfac=sample(letters[10 + (1:3)],nobs,replace=TRUE)) 
mydat$x <- seq(0,1,length.out=nobs) + 0.33 * mydat$grp
mydat$y <- 0.25 * rnorm(nobs) + 2 * mydat$grp
mydat$grp <- factor(mydat$grp)
mydat$se  <- sqrt(mydat$x)

ggplot(mydat,aes(x=x,y=y,ymin=y-se,ymax=y+se,color=grp)) +
facet_grid(rowfac ~ colfac) + 
geom_line() + 
geom_errorbar() + 
labs(title='uncertainty by errorbar')

ggplot(mydat,aes(x=x,y=y,ymin=y-se,ymax=y+se,fill=grp)) +
facet_grid(rowfac ~ colfac) + 
geom_line() + 
geom_cloud(steps=15,max_alpha=0.85) +
labs(title='uncertainty by cloudr')

Example output

Loading required package: ggplot2

ggallin documentation built on May 1, 2019, 10:54 p.m.