View source: R/geom_interval.R
stat_interval | R Documentation |
geom_interval
stat_interval(
mapping = NULL,
data = NULL,
geom = GeomInterval,
position = "identity",
interval = 0.8,
fun_middle = "median",
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
geom_interval(
mapping = NULL,
data = NULL,
stat = "interval",
position = "identity",
...,
fun_middle = "median",
interval = 0.8,
alpha.line = 0.7,
param_ensemble = list(),
param_slope = list(alpha = 1, linewidth = 1),
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
mapping |
Set of aesthetic mappings created by |
data |
The data to be displayed in this layer. There are three options: If A A |
geom |
The geometric object to use to display the data for this layer.
When using a
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
interval |
interval of confidence interval, default is 0.8 |
fun_middle |
function to calculate middle value, default is median |
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
inherit.aes |
If |
... |
Other arguments passed on to
|
stat |
The statistical transformation to use on the data for this layer.
When using a
|
alpha.line |
alpha of ensemble line |
param_ensemble |
list of parameters for ensemble line |
param_slope |
list of parameters for slope line |
library(ggplot2)
df <- CMIP6_HWD
p <- ggplot(df, aes(year, value, color = prob, fill = prob))
# both line and fill
p + geom_interval(alpha = 0.2, alpha.line = 1,
linewidth = 0.7, linetype = 2, # for ensemble line
param_slope = list(linewidth = 1, alpha = 1, linetype = 1), # slope line
interval = 0.8, fun_middle = "mean")
# only line
p + geom_interval(
fill = "NA",
alpha = 0.4, interval = 0.8, fun_middle = "mean", linewidth = 0.4
) +
theme(legend.key = element_rect(fill = "NA"))
# only fill
p + geom_interval(
color = "NA", key_glyph = "polygon2",
alpha = 0.4, interval = 0.8, fun_middle = "mean", linewidth = 0.4
) +
theme(legend.key = element_rect(fill = "NA"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.