Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Point density plots #18

Open
Aariq opened this issue Feb 9, 2024 · 3 comments
Open

Point density plots #18

Aariq opened this issue Feb 9, 2024 · 3 comments
Labels
figures New figures or improvements to existing figures priority: low

Comments

@Aariq
Copy link
Collaborator

Aariq commented Feb 9, 2024

In #10 I discussed making scatter plots and one of the downsides is the extreme overplotting if entire datasets are used. ggpointdensity provides an alternative that is between a scatter plot and a density plot. However, the current methods it uses for calculating bandwidth and the density kernel fail with large zero-inflated datasets.

I've figured out working alternative methods for both of these, using bw.nrd0() for bandwidth estimation instead of bw.nrd() and using KernSmooth::bkde2D() for density kernel estimation instead of MASS::kde2d(). I understand ggpointdensity well enough to make a PR to introduce this method, I think, but the package author has been unresponsive to similar PRs (LKremer/ggpointdensity#23) introducing improved methods. I'd probably end up having to install from my fork or just replicate much of what ggpointdensity does in a script (i.e. rather than creating a new geom_, just do the calculations and plot data with geom_point(aes(color = density))).

It's too bad this is so tough because this is a perfect application for a point density plot.

@Aariq Aariq added figures New figures or improvements to existing figures priority: medium labels Feb 9, 2024
@LKremer
Copy link

LKremer commented May 16, 2024

Hi @Aariq , I was pretty busy in the past few months, but now I have some time to revisit ggpointdensity. I'd be happy to merge a pull request that implements your proposed density estimation method. Ideally this would be an option to the geom_pointdensity function, used via e.g. geom_pointdensity(method='bkde2D') (or whatever you want to call it). If this method turns out to be superior to the current default method, I will think about making it the default in future version.

@Aariq
Copy link
Collaborator Author

Aariq commented May 16, 2024

Cool! I'll take a look at what I did here again in the upcoming weeks and see if I can make a PR.

@Aariq
Copy link
Collaborator Author

Aariq commented May 16, 2024

Note to self: I think most of the relevant code is here: https://github.com/EcosystemEcologyLab/SW_Biomass/blob/main/notes/kernel_estimation.R

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
figures New figures or improvements to existing figures priority: low
Projects
None yet
Development

No branches or pull requests

2 participants