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

Heatmaps outside geom_ttile #6124

Open
fwunschel opened this issue Sep 27, 2024 · 3 comments
Open

Heatmaps outside geom_ttile #6124

fwunschel opened this issue Sep 27, 2024 · 3 comments

Comments

@fwunschel
Copy link

Hi All,

Have loved all things geom_sf has done in advancing ggplot2, and have done some work with the geom_tile() function. I was wondering if there were plans to add a more fluid heat map (thinking a geom_smooth version for points) option or integrate sf objects in geom_tile(). If anyone has any tips or tricks to emulate a less pixelated heat map, sin generating infinitely smaller tile size, that would be great as well.

Thanks for all the work on this!

All the Best,
Frankie

@teunbrand
Copy link
Collaborator

Hi there, can you point to an example of the thing you'd like to do in ggplot2, but is currently impossible/cumbersome?
I have a hard time imagining what a fluid heat map, or geom_smooth for points would look like.

@fwunschel
Copy link
Author

Something like this heatmap, rather than this more pixelized example. The difference im seeking is in the fluidity of color transition, the overlap on a map and the use of spatial typed variables - but maybe I just need to decipher a smaller pixel size and use an x y configuration rather than geometry I can achieve something similar?

@teunbrand
Copy link
Collaborator

For spatial data, it might be more convenient to look into specialised packages for handling raster data, like {terra}.
In terms of colour fluidity, there is geom_raster(interpolate = TRUE) that can 'blend' adjacent colours. There are a few more constraints on geom_raster() than on geom_tile() though.

library(ggplot2)

p <- ggplot(
  data.frame(
    x = c(1, 2, 1, 2),
    y = c(1, 1, 2, 2),
    g = LETTERS[1:4]
  ),
  aes(x, y, fill = g)
)

p + geom_raster()

p + geom_raster(interpolate = TRUE)

Created on 2024-10-03 with reprex v2.1.1

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

2 participants