我正在使用R中的Plotly创建一个交互式 map (形状). map 显示不同部门的#频率.但是,将鼠标悬停在多边形中心时,不会显示包含部门信息的工具提示.仅当鼠标悬停在多边形的边上时,才会显示工具提示.
我试过使用工具提示#配置中的层和位置属性,但工具提示仍然不一致地显示在多边形的中心#中.
我非常感激任何建议或解决方案,使工具提示显示在#多边形的中心时,悬停在 map 上.
maa = read_sf("map.shp")
map = map %>% mutate(across(c("Frecuency", "Im", "Fo", "April", "July"),
~ifelse(is.na(.), 0, .)))
g_map = map %>%
ggplot(aes(fill = Frecuency, text = paste("Dp: ", NAME, "",
"Frecuency: ", Frecuency, "","I: ", Im, "
",
"F: ", Fo, "
",
"Abril: ", April, "
",
"Julio: ", July))) +
geom_sf() +
scale_fill_gradient(low = "white", high = "darkblue") +
labs(fill = "Scale", title = "Title") +
theme_minimal() +
theme_void()+
theme(axis.line = element_blank())
# Convert to plotly
g_mapa_int = ggplotly(g_map, tooltip = "text")%>%
config(displayModeBar = FALSE) %>%
config(showLink = FALSE)
# Print
g_mapa_int
我非常感谢任何建议或解决方案,使工具提示显示在中心的多边形时,悬停在 map 上.