Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no heatmap is shown when scales of x and y axis are very different #20

Open
frederikziebell opened this issue May 23, 2022 · 3 comments

Comments

@frederikziebell
Copy link

This

set.seed(1)
tibble(
  x = runif(1e5,max=10),
  y = rnorm(1e5, sd=1e-4)
) %>% 
  ggplot(aes(x,y)) +
    ggpointdensity::geom_pointdensity()

results in:

image

Does ggpointdensity compute the neighborhood-radius relative to the dynamic range of the respective axes? I think that might be the issue here.

@frederikziebell frederikziebell changed the title not heatmap is shown, when scales of x and y axis are very different no heatmap is shown when scales of x and y axis are very different May 23, 2022
@LKremer
Copy link
Owner

LKremer commented Nov 25, 2022

That's definitely a bug but I'm not sure where it originates. Once I find the time, I will try to hunt this down. For now I can offer this workaround:

  • install the latest ggpointdensity version from GitHub: remotes::install_github("LKremer/ggpointdensity")
  • use the 'kde2d' method to calculate the point density instead of the default method
set.seed(1)
tibble(
    x = runif(1e5,max=10),
    y = rnorm(1e5, sd=1e-4)
) %>% 
    ggplot(aes(x,y)) +
    ggpointdensity::geom_pointdensity(method="kde2d")

image

This kde2d method is slower for very few points, but faster for very many points. It's not on CRAN yet, so that's why you have to reinstall the package from GitHub.

@qimiaonnegliguo
Copy link

ggplot(data = data, mapping = aes(x=UMAP_1,y=UMAP_2))+ggpointdensity::geom_pointdensity(method="kde2d")
Warning message:
In ggpointdensity::geom_pointdensity(method = "kde2d") :
Ignoring unknown parameters: method

Thank you for your powerful tool. I used the code I attached here, referring your reply. But I continue to get the error that method parameter is ignored. Could you help to see the issue? Thank you so much.

@LKremer
Copy link
Owner

LKremer commented Jul 26, 2023

Hi @qimiaonnegliguo,
I guess you installed the package from CRAN, which doesn't have the latest version yet.
Could you try re-installing the package from GitHub like so?
remove.packages("ggpointdensity")
and then, to install, the latest version:
devtools::install_github("LKremer/ggpointdensity")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants