How to make tooltips show in region rather than on border (map using ggplotly)

I have a choropleth map that is made using geom_sf and am plotting it using plotly.

The tooltips don’t seem to be working quite right. I hover over some bits of a region, I will get the tooltip, but if I hover over other bits, I won’t. I think they are showing up on the borders rather than in the region themselves (though other versions of this map are a bit less clear and seem to swim over into other regions, for e.g.).

Does anybody know any way to make the tooltip show regardless of which part of the region you hover over, and to ensure they are confined to their region only?

This is an example of what I’m doing:


us <- st_as_sf(map("state", plot = FALSE, fill = TRUE))

us$random_number <- sample(100, size = nrow(us), replace = TRUE)

us_plot <- ggplotly(ggplot(us, aes(text = paste(ID))) + 
            geom_sf(aes(fill = random_number)) + 
            ggtitle("Random numbers")  +


add this
%>% style(hoveron = “fill”)