将鼠标悬停在数据点上时无法看到文本框

时间:2017-08-21 13:14:13

标签: r plotly

参考this

 g <- list(showframe = FALSE,
      coastlinecolor = toRGB("white"),
      showland = TRUE,
      landcolor = toRGB("gray80"),
      showcountries = TRUE,
      countrycolor = toRGB("white"),
      countrywidth = 0.2,
      projection = list(type = 'Mercator'))

plot_geo(New_A_loc,
     marker = list(color = toRGB("purple"),
                   opacity = 0.5,
                   line = list(color = toRGB("purple"),
                               width = 0.5))) %>%
  add_markers(
     data = New_A_loc, x = ~Long, y = ~Lat,
     hoverinfo = "text",text = ~City, alpha = 0.5
      ) %>%
 layout(geo = g)

Full code with data。我面临的问题是,当我将鼠标移到数据点上时,我无法查看显示的文本框。我使用上述博主使用的相同方式,但我无法达到结果。

1 个答案:

答案 0 :(得分:0)

您可以跳过add_markers部分,并将所有内容放在plot_geo声明中。

plot_geo(New_A_loc, 
         lat = ~Lat, 
         lon = ~Long,
         text = ~City,
         mode='markers',
         marker = list(color = toRGB("purple"),
                       opacity = 0.5,
                       line = list(color = toRGB("purple"),
                                   width = 0.5))
        ) %>%
  layout(geo = g)

enter image description here