A combination of stat_summary / stat_summaryh and
geom_interval / geom_intervalh with sensible defaults.
While the corresponding geoms are intended for use on
data frames that have already been summarized using a point_interval
function, these stats are intended for use directly on data frames of draws, and
will perform the summarization using a point_interval function.
stat_interval(mapping = NULL, data = NULL, geom = "interval",
position = "identity", ..., point_interval = median_qi,
fun.data = NULL, .width = c(0.5, 0.8, 0.95), .prob,
fun.args = list(), na.rm = FALSE, show.legend = NA,
inherit.aes = TRUE)stat_intervalh(mapping = NULL, data = NULL, geom = "intervalh",
position = "identity", ..., point_interval = median_qi,
fun.data = NULL, .width = c(0.5, 0.8, 0.95), .prob,
fun.args = list(), na.rm = FALSE, show.legend = NA,
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.
Use to override the default connection between
geom_interval/geom_interval and stat_interval/stat_intervalh.
The position adjustment to use for overlapping points on this layer.
Other arguments passed to layer. They may also be arguments to the paired geom.
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 y-based aesthetics for stat_interval and the
x-based aesthetics for stat_intervalh. See the point_interval family of functions.
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.
The .width argument passed to point_interval.
Deprecated. Use .width instead.
Other optional arguments passed to fun.data.
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? NA, the default, includes if any aesthetics
are mapped. FALSE never includes, and TRUE always includes.
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.
See geom_interval / geom_intervalh for the geom versions, intended for use on
intervals that have already been summarized using a point_interval function.
See stat_pointinterval / stat_pointintervalh for a similar stat intended for
point summaries and intervals.
# NOT RUN {
library(magrittr)
library(ggplot2)
data(RankCorr, package = "tidybayes")
RankCorr %>%
spread_draws(u_tau[i]) %>%
ggplot(aes(y = i, x = u_tau)) +
stat_intervalh() +
scale_color_brewer()
RankCorr %>%
spread_draws(u_tau[i]) %>%
ggplot(aes(x = i, y = u_tau)) +
stat_interval() +
scale_color_brewer()
# }
Run the code above in your browser using DataLab