How to fit an image into a sf and ggplot map in r and add an onclick function?

29 Views Asked by At

I would like to fit an image into this map plot in r. How can I add an onclick function
to each country in the plotly plot. Are there any themes in r that can be used on hover text box?

africa.plot <- ggplot() +
  geom_sf(data = africa) +
  geom_sf(data = selected_africa, aes(), fill = "transparent", color = "brown") +  # Highlight selected countries
  geom_sf_text(data = selected_africa, aes(label = name_long), color = "black", size = 3, nudge_y = 0.1) +
  theme_void()

africa_plotly <- ggplotly(africa.plot, tooltip = "text")
0

There are 0 best solutions below