ggalt
ggalt copied to clipboard
Add ndensity computed group stat to StatBkde2d
Gives stat_bkde2d()
the same behavior as stat_density2d()
-- normalizing the density to the max density per group when facetting. Similar to the nlevel
computed stat.
Before (density)
library(ggplot2)
library(ggalt) # from seasmith/ggalt branch add-ndensity
ggplot(iris, aes(Sepal.Length, Petal.Length)) +
stat_bkde2d(aes(fill = stat(density)), geom = "raster", contour = FALSE) +
facet_wrap(vars(Species))
After (ndensity)
ggplot(iris, aes(Sepal.Length, Petal.Length)) +
stat_bkde2d(aes(fill = stat(ndensity)), geom = "raster", contour = FALSE) +
facet_wrap(vars(Species))
Very welcome addition! Can you also add yourself to the DESCRIPTION?