gf_ridgeline | R Documentation |
Formula interface to ggridges plots
gf_ridgeline(
object = NULL,
gformula = NULL,
data = NULL,
...,
height,
scale = 1,
min_height = 0,
color,
fill,
alpha,
group,
linetype,
linewidth,
point_size,
point_shape,
point_colour,
point_fill,
point_alpha,
point_stroke,
xlab,
ylab,
title,
subtitle,
caption,
geom = "ridgeline",
stat = "identity",
position = "identity",
show.legend = NA,
show.help = NULL,
inherit = TRUE,
environment = parent.frame()
)
gf_density_ridges(
object = NULL,
gformula = NULL,
data = NULL,
...,
height,
scale = 1,
rel_min_height = 0,
color,
fill,
alpha,
group,
linetype,
linewidth,
point_size,
point_shape,
point_colour,
point_fill,
point_alpha,
point_stroke,
panel_scaling = TRUE,
xlab,
ylab,
title,
subtitle,
caption,
geom = "density_ridges",
stat = "density_ridges",
position = "points_sina",
show.legend = NA,
show.help = NULL,
inherit = TRUE,
environment = parent.frame()
)
gf_density_ridges2(
object = NULL,
gformula = NULL,
data = NULL,
...,
height,
scale = 1,
rel_min_height = 0,
color,
fill,
alpha,
group,
linetype,
linewidth,
point_size,
point_shape,
point_colour,
point_fill,
point_alpha,
point_stroke,
panel_scaling = TRUE,
xlab,
ylab,
title,
subtitle,
caption,
geom = "density_ridges2",
stat = "density_ridges",
position = "points_sina",
show.legend = NA,
show.help = NULL,
inherit = TRUE,
environment = parent.frame()
)
gf_density_ridgeline_gradient(
object = NULL,
gformula = NULL,
data = NULL,
...,
height,
color,
fill,
alpha,
group,
linetype,
linewidth,
gradient_lwd = 0.5,
xlab,
ylab,
title,
subtitle,
caption,
geom = "ridgeline_gradient",
stat = "identity",
position = "identity",
show.legend = NA,
show.help = NULL,
inherit = TRUE,
environment = parent.frame()
)
gf_density_ridges_gradient(
object = NULL,
gformula = NULL,
data = NULL,
...,
height,
panel_scaling = TRUE,
color,
fill = ~stat(x),
alpha,
group,
linetype,
linewidth,
gradient_lwd = 0.5,
xlab,
ylab,
title,
subtitle,
caption,
geom = "density_ridges_gradient",
stat = "density_ridges",
position = "points_sina",
show.legend = NA,
show.help = NULL,
inherit = TRUE,
environment = parent.frame()
)
object |
When chaining, this holds an object produced in the earlier portions of the chain. Most users can safely ignore this argument. See details and examples. |
gformula |
A formula with shape |
data |
The data to be displayed in this layer. There are three options: If A A |
... |
Additional arguments. Typically these are
(a) ggplot2 aesthetics to be set with |
height |
The height of each ridgeline at the respective x value.
Automatically calculated and provided by |
scale |
A scaling factor to scale the height of the ridgelines relative to the spacing between them. A value of 1 indicates that the maximum point of any ridgeline touches the baseline right above, assuming even spacing between baselines. |
min_height |
A height cutoff on the drawn ridgelines. All values that fall below this cutoff will be removed. The main purpose of this cutoff is to remove long tails right at the baseline level, but other uses are possible. The cutoff is applied before any height scaling is applied via the scale aesthetic. Default is 0, so negative values are removed. |
color |
A color or a formula used for mapping color. |
fill |
A color for filling, or a formula used for mapping fill. |
alpha |
Opacity (0 = invisible, 1 = opaque). |
group |
Used for grouping. |
linetype |
A linetype (numeric or "dashed", "dotted", etc.) or a formula used for mapping linetype. |
linewidth |
A numerical line width or a formula used for mapping linewidth. |
point_shape, point_colour, point_size, point_fill, point_alpha, point_stroke |
As in |
xlab |
Label for x-axis. See also |
ylab |
Label for y-axis. See also |
title, subtitle, caption |
Title, sub-title, and caption for the plot.
See also |
geom, stat |
Use to override the default connection between
|
position |
Position adjustment, either as a string naming the adjustment
(e.g. |
show.legend |
logical. Should this layer be included in the legends?
|
show.help |
If |
inherit |
A logical indicating whether default attributes are inherited. |
environment |
An environment in which to look for variables not found in |
rel_min_height |
Lines with heights below this cutoff will be removed. The cutoff is
measured relative to the overall maximum, so |
panel_scaling |
If |
gradient_lwd |
A parameter to needed to remove rendering artifacts inside the rendered gradients. Should ideally be 0, but often needs to be around 0.5 or higher. |
Note that the ggridges::stat_density_ridges()
makes joint density estimation
across all datasets. This may not generate the desired result when using
faceted plots. As an alternative, you can set stat = "density"
to use
ggplot2::stat_density()
. In this case, it is required to add the aesthetic mapping
height = after_stat(density)
(see examples).
ggridges::geom_density_ridges()
ggridges::geom_ridgeline()
ggridges::geom_density_ridges_gradient()
data.frame(
x = rep(1:5, 3), y = c(rep(0, 5), rep(1, 5), rep(3, 5)),
height = c(0, 1, 3, 4, 0, 1, 2, 3, 5, 4, 0, 5, 4, 4, 1)
) |>
gf_ridgeline(y ~ x, height = ~ height, group = ~y, fill = "lightblue", alpha = 0.7)
diamonds |>
gf_density_ridges(cut ~ price,
scale = 2, fill = ~ cut, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
diamonds |>
gf_density_ridges(clarity ~ price | cut,
scale = 2, fill = ~ clarity, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
## Not run:
diamonds |>
gf_density_ridges(clarity ~ price | cut, height = ~after_stat(density), stat = "density",
scale = 2, fill = ~ clarity, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
## End(Not run)
## Not run:
diamonds |>
gf_density_ridges2(cut ~ price, scale = 2, fill = ~ cut, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
## End(Not run)
diamonds |>
gf_density_ridges(cut ~ price,
scale = 2, fill = ~ cut, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
diamonds |>
gf_density_ridges(clarity ~ price | cut,
scale = 2, fill = ~ clarity, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
## Not run:
diamonds |>
gf_density_ridges(clarity ~ price | cut, height = ~ after_stat(density), stat = "density",
scale = 2, fill = ~ clarity, alpha = 0.6, show.legend = FALSE) |>
gf_theme(theme_ridges()) |>
gf_refine(
scale_y_discrete(expand = c(0.01, 0)),
scale_x_continuous(expand = c(0.01, 0))
)
## End(Not run)
## Not run:
mosaicData::Weather |>
gf_density_ridges_gradient(month ~ high_temp | city ~ ., fill = ~stat(x),
group = ~ month, show.legend = FALSE, rel_min_height = 0.02) |>
gf_refine(scale_fill_viridis_c(option = "B"), theme_bw())
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.