ggpointdensity icon indicating copy to clipboard operation
ggpointdensity copied to clipboard

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

Open frederikziebell opened this issue 2 years ago • 3 comments

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 avatar May 23 '22 08:05 frederikziebell

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.

LKremer avatar Nov 25 '22 13:11 LKremer

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.

qimiaonnegliguo avatar Jul 26 '23 08:07 qimiaonnegliguo

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

LKremer avatar Jul 26 '23 09:07 LKremer