plot_density_class: Plot density per class

View source: R/graphics.R

plot_density_classR Documentation

Plot density per class

Description

Kernel density plot grouped by a class label.

Usage

plot_density_class(
  data,
  class_label,
  label_x = "",
  label_y = "",
  colors = NULL,
  bin = NULL,
  alpha = 0.5
)

Arguments

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 geom_density

alpha

fill transparency (0–1)

Details

Expects data with a grouping column named in class_label and one numeric column. Each group is filled with a distinct color (if provided).

Value

returns a ggplot2::ggplot graphic

Examples

grf <- plot_density_class(iris |> dplyr::select(Sepal.Width, Species),
class = "Species", colors=c("red", "green", "blue"))
plot(grf)

daltoolbox documentation built on Nov. 5, 2025, 7:09 p.m.