Modified versions of geom_pointrange
and geom_pointrangeh
with default aesthetics
designed for use with output from point_interval
.
geom_pointinterval(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., size_domain = c(1, 6),
size_range = c(0.6, 1.4), fatten_point = 1.8, na.rm = FALSE,
show.legend = c(size = FALSE), inherit.aes = TRUE)geom_pointintervalh(mapping = NULL, data = NULL, stat = "identity",
position = "identity", ..., size_domain = c(1, 6),
size_range = c(0.6, 1.4), fatten_point = 1.8, na.rm = FALSE,
show.legend = c(size = FALSE), inherit.aes = TRUE)
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.
A layer specific dataset - only needed if you want to override the plot defaults.
The statistical transformation to use on the data for this layer.
The position adjustment to use for overlapping points on this layer.
Other arguments passed to layer
.
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.)
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).
A multiplicative factor used to adjust the size of the point relative to the size of the thickest line.
If FALSE
, the default, missing values are removed with a warning. If TRUE
, missing
values are silently removed.
Should this layer be included in the legends? Default is c(size = FALSE)
, unlike most geoms,
to match its common use cases. FALSE
hides all legends, TRUE
shows all legends, and NA
shows only
those that are mapped (the default for most geoms).
If FALSE
, overrides the default aesthetics, rather than combining with them. This is
most useful for helper functions that define both data and aesthetics and shouldn't inherit behavior from the
default plot specification, e.g. borders.
geom_pointinterval
is a modified version of geom_pointrange
, and geom_pointintervalh
is
a modified version of geom_pointrangeh
. These geoms set some default aesthetics equal
to the .lower
, .upper
, and .width
columns generated by the point_interval
family
of functions, making them often more convenient than vanilla geom_pointrange
or
geom_pointrangeh
when used with functions like median_qi
, mean_qi
,
mode_hdi
, etc.
Specifically, geom_pointinterval
acts as if its default aesthetics are
aes(ymin = .lower, ymax = .upper, size = -.width)
. geom_pointintervalh
acts as if its default
aesthetics are aes(xmin = .lower, xmax = .upper, size = -.width)
.
Both geoms provides a scaling factor for line width as well as point size through the fatten.interval
and
fatten.point
arguments; this scaling factor is designed to give multiple probability intervals reasonable
scaling at the default settings for scale_size_continuous
. Finally, these geoms default to not
displaying the legend, though this can be overridden through setting show.legend = NA
(the setting for most
geoms) or show.legend = TRUE
.
See geom_lineribbon
for a similar geom designed for curves plus probability bands. See
geom_pointrange
and geom_pointrangeh
for the geoms these are based on.
# NOT RUN {
library(magrittr)
library(ggplot2)
data(RankCorr, package = "tidybayes")
RankCorr %>%
spread_draws(u_tau[i]) %>%
median_qi(.width = c(.8, .95)) %>%
ggplot(aes(y = i, x = u_tau)) +
geom_pointintervalh()
RankCorr %>%
spread_draws(u_tau[i]) %>%
median_qi(.width = c(.8, .95)) %>%
ggplot(aes(x = i, y = u_tau)) +
geom_pointinterval()
# }
Run the code above in your browser using DataLab