【问题标题】:Adding Hover Text (R Plotly Map)添加悬停文本(R Plotly Map)
【发布时间】:2021-04-19 13:53:57
【问题描述】:

我想将悬停文本添加到此地图(来自 ~IntZoneName),但找不到方法。 我使用分散是正确的吗? 我正在使用已与数据框连接的空间文件,然后使用 Plotly 使图形交互。目前悬停只是显示来自 ~CrudeRate7DayPositive 的数据。

plot_ly(map_x,
        type = "scatter",
        color = ~CrudeRate7DayPositive,
        colors = cols,
        text = ~IntZoneName, 
        hoverinfo = "text",
        alpha = 0.8) %>% 
        layout(title = "Crude Rates") 

【问题讨论】:

    标签: r plotly r-plotly


    【解决方案1】:

    我放弃了阴谋并选择了 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-06
      • 2018-09-04
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 2015-04-10
      • 2022-01-01
      • 1970-01-01
      相关资源
      最近更新 更多