I am trying to use geom_raster_interactive in ggiraph to create a map where I can view values of each grid cell using the tooltip function. However, when I set tooltip = value, the tooltip returns the same value for every grid cell in the tooltip.
I modified the code from the gome_raster_interactive example below to demonstrate the issue. I would like to be able to hover over the grid cell location and see the values of z in the tooltip, but this doesn't work. Thank you for any suggestions!
library(ggplot2)
library(ggiraph)
df <- expand.grid(x = 0:5, y = 0:5)
df$z <- runif(nrow(df))
gg <- ggplot(df, aes(x, y, fill = z, tooltip = z)) +
geom_raster_interactive()
x <- girafe(ggobj = gg)
if(interactive()) print(x)
You can use the
geom_tile_interactive()
function to obtain the desirable results.