plot_density: Plot density

View source: R/graphics.R

plot_densityR Documentation

Plot density

Description

Kernel density plot for one or multiple numeric columns.

Usage

plot_density(
  data,
  label_x = "",
  label_y = "",
  colors = NULL,
  bin = NULL,
  alpha = 0.25
)

Arguments

data

data.frame with one or more numeric columns

label_x

x‑axis label

label_y

y‑axis label

colors

optional fill color (single column) or vector for groups

bin

optional bin width passed to geom_density

alpha

fill transparency (0–1)

Details

If data has multiple numeric columns, densities are overlaid and filled by column (group). When a single column is provided, colors (if set) is used as a constant fill. The bin argument is passed to geom_density(binwidth=...).

Value

returns a ggplot2::ggplot graphic

Examples

grf <- plot_density(iris |> dplyr::select(Sepal.Width), colors="blue")
plot(grf)

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