[英]Adding Hover Text (R Plotly Map)
我想将 hover 文本添加到此 map(来自 ~IntZoneName),但找不到方法。 我使用分散是正确的吗? 我正在使用我与 dataframe 连接的空间文件,然后使用 Plotly 使图形交互。 目前 hover 仅显示来自 ~CrudeRate7DayPositive 的数据。
plot_ly(map_x,
type = "scatter",
color = ~CrudeRate7DayPositive,
colors = cols,
text = ~IntZoneName,
hoverinfo = "text",
alpha = 0.8) %>%
layout(title = "Crude Rates")
我放弃了 plotly 并选择了 ggiraph,它做了我想做的一切
gg <- ggplot(map_x) +
geom_sf_interactive(aes(fill = CrudeRate7DayPositive,
tooltip = c(paste0(IntZoneName, "\n",CrudeRate7DayPositive, " cases per 100,000 \n (7 Day Crude Rate)")),
data_id = IntZoneName)) +
scale_fill_brewer(palette = "Purples") +
theme_void()
x <- girafe(ggobj = gg)
x <- girafe_options(x,
opts_zoom(min = 0.7, max = 2) )
if( interactive() ) print(x)
对我来说,一个简单的“打字错误”是原因; 我注意到这些参考文献之间的区别: 1和2 。 看起来hoveron='fill'
与hoveron='fills'
有很大的不同,这取决于我想你使用的是什么版本。
Plotly 参考也有助于基本事实... https://plotly.com/r/reference/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.