Explore numeric columns with Density plot

Author

Francisco Zambrano

Published

July 1, 2023

Installation

Development version from GitHub:

GitHub: https://github.com/zpio/ggexplorer

Show/Hide code
remotes::install_github("zpio/ggexplorer")
Show/Hide code
library(ggexplorer)

Examples

Iris dataset

Show/Hide code
iris

Basic Chart

Show/Hide code
plotDensity(iris)

Fill

Show/Hide code
plotDensity(iris, fill = "steelblue")

Opacity

Show/Hide code
plotDensity(iris, alpha = 0.5)

Number of facet columns

Show/Hide code
plotDensity(iris, alpha = 0.5, ncol = 2, fill = "steelblue")

Adjust

Show/Hide code
plotDensity(iris, alpha = 0.5, adjust = 2)

Scales

Show/Hide code
plotDensity(iris, scales = "free_x")

Histogram

Show/Hide code
plotDensity(iris, alpha = .5, show_histogram = TRUE)

Boxplot

Show/Hide code
plotDensity(iris, show_boxplot = TRUE, fill = "steelblue", alpha = 0.5)

Fill by

Show/Hide code
plotDensity(iris, alpha = 0.5, fill_var = Species)

Legend Position

Show/Hide code
plotDensity(iris, alpha = 0.5, fill_var = Species, legend_position = "bottom")

Colour scales

Show/Hide code
plotDensity(iris, alpha = 0.5, fill_var = Species) +
  ggplot2::scale_fill_viridis_d() +
  ggplot2::scale_color_viridis_d()

Interactive

Show/Hide code
plotDensity(iris, fill = "steelblue", interactive = TRUE)