Generates a combination of a density and stat_pointintervalh representing the density, point summary, and uncertainty intervals for draws from a distribution. Useful for representing posteriors from Bayesian models; in that context the mirrored version is variously called an eye plot, a raindrop plot, violin plot; hence "half-eye" for this plot.

geom_halfeyeh(mapping = NULL, data = NULL, position = "identity",
  trim = TRUE, scale = "area", relative_scale = 1, fill = NULL,
  density.color = NA, ..., point_interval = median_qi,
  fun.data = NULL, fun.args = list(), .width = c(0.66, 0.95), .prob,
  color = NULL, size = NULL, size_domain = NULL, size_range = NULL,
  fatten_point = NULL)

Arguments

mapping

The aesthetic mapping, usually constructed with aes or aes_string. Only needs to be set at the layer level if you are overriding the plot defaults.

data

A layer specific dataset - only needed if you want to override the plot defaults.

position

The position adjustment to use for overlapping points on this layer.

trim

If TRUE (default), trim the tails of the density to the range of the data. If FALSE, don't trim the tails.

scale

If "area" (default), all densities have the same area (before trimming the tails). If "count", areas are scaled proportionally to the number of observations. If "width", all densities have the same maximum width/height.

relative_scale

A relative scaling factor to determine how much of the available space densities are scaled to fill: if 1, all available space is filled.

fill

Fill color of the density.

density.color

Outline color of the density. The default, NA, suppresses the density outline. Set to another value to set the density outline color manually, or set to NULL if you want the outline color of the density to be determined by the aesthetic mapping.

...

Currently unused.

point_interval

A function that when given a vector should return a data frame with variables y, ymin, ymax, and .width; or x, xmin, xmax, and .width. Either is acceptable: output will be converted into the x-based aesthetics geom_halfeyeh. See the point_interval family of functions.

fun.data

Similar to point_interval, for compatibility with stat_summary. Note: if the summary function is passed using fun.data, the x and y-based aesthetics are not converted to the correct form automatically.

fun.args

Optional arguments passed to fun.data.

.width

The .width argument passed to point_interval.

.prob

Deprecated. Use .width instead.

color

Passed to stat_pointintervalh. Color of the point summary and uncertainty interval.

size

Passed to stat_pointintervalh. Line weight of the point summary and uncertainty interval.

size_domain

The minimum and maximum of the values of the size aesthetic that will be translated into actual sizes drawn according to size_range (see the documentation for that argument, below.)

size_range

This geom scales the raw size aesthetic values, as they tend to be too thick when using the default settings of scale_size_continuous, which give sizes with a range of c(1, 6). The size_domain value indicates the input domain of raw size values (typically this should be equal to the value of the range argument of the scale_size_continuous function), and size_range indicates the desired output range of the size values (the min and max of the actual sizes used to draw intervals).

fatten_point

A multiplicative factor used to adjust the size of the point relative to the size of the thickest line.

Details

A half-eye plot is a compact visual summary of the distribution of a sample, used (under various names and with subtle variations) to visualize posterior distributions in Bayesian inference. This instantiation is a combination of a density plot, point summary, and one or more uncertainty intervals.

geom_halfeyeh() is roughly equivalent to geom_density_ridges() + stat_pointintervalh() with some reasonable defaults, including color choices and the use of median with 95% and 66% quantile intervals.

See also

See geom_eye and geom_eyeh for the mirrored-density (full "eye") versions. See geom_density_ridges and stat_summaryh for the geoms this function is based on.

Examples

library(magrittr) library(ggplot2) data(RankCorr, package = "tidybayes") RankCorr %>% spread_draws(u_tau[i]) %>% ggplot(aes(y = i, x = u_tau)) + geom_halfeyeh()