Closed bjreisman closed 4 years ago
Did you end up making a package for this (I faintly remember seeing something for that). If not I'll happily accept a PR
I did not, but @LKremer did as a standalone package: https://github.com/LKremer/ggpointdensity Thanks for considering it!
(Originally proposed for in ggplot2 as issue 3150)
One geom/stat which would be very useful is a hybrid between geom_density_2d and geom_point, where points are colored by their density. This would help avoid overcome overplotting by mapping the density to the color aesthetic, while preserving the individual points in areas of low density. This type of visualization is very common in flow cytometry, but could be useful elsewhere as well.
@slowkow has an excellent example of how to achieve the desired effect here, but it requires computing the density at each point prior to plotting, which becomes burdensome for faceted plots.
I was able to modify the
stat_density_2d
function slightly using @slowkow's code as a guide to make a newstat_density_point_2d
function which worked well in my hands(example below), but I had trouble writing the corresponding geom. Is this something that could be considered for inclusion in ggforce?I'd be happy to contribute my version, thought there may be a better way to achieve the same goal.
Thanks for your consideration!