| plot_density_class | R Documentation |
Kernel density plot grouped by a class label.
plot_density_class(
data,
class_label,
label_x = "",
label_y = "",
colors = NULL,
bin = NULL,
alpha = 0.5
)
data |
data.frame with class label and a numeric column |
class_label |
name of the grouping (class) column |
label_x |
x‑axis label |
label_y |
y‑axis label |
colors |
optional vector of fills per class |
bin |
optional bin width passed to |
alpha |
fill transparency (0–1) |
Expects data with a grouping column named in class_label and one numeric column. Each group is
filled with a distinct color (if provided).
returns a ggplot2::ggplot graphic
grf <- plot_density_class(iris |> dplyr::select(Sepal.Width, Species),
class = "Species", colors=c("red", "green", "blue"))
plot(grf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.