powered by
This function generates a density plot from a data frame containing numeric values using ggplot2. If the data frame has multiple columns, densities can be grouped and plotted.
plot_density( data, label_x = "", label_y = "", colors = NULL, bin = NULL, alpha = 0.25 )
returns a ggplot graphic
data.frame contain x, value, and variable
x-axis label
y-axis label
color vector
bin width for density estimation
level of transparency
grf <- plot_density(iris |> dplyr::select(Sepal.Width), colors="blue") plot(grf)
Run the code above in your browser using DataLab