ggalt icon indicating copy to clipboard operation
ggalt copied to clipboard

Add ndensity computed group stat to StatBkde2d

Open seasmith opened this issue 4 years ago • 1 comments

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))

before-ndensity

After (ndensity)

ggplot(iris, aes(Sepal.Length, Petal.Length)) +
    stat_bkde2d(aes(fill = stat(ndensity)), geom = "raster", contour = FALSE) +
    facet_wrap(vars(Species))

with-ndensity

seasmith avatar Jul 05 '19 19:07 seasmith

Very welcome addition! Can you also add yourself to the DESCRIPTION?

hrbrmstr avatar Jul 05 '19 19:07 hrbrmstr