我正在尝试在R中使用plotly创建热图,并且被困在图表中相应状态的注释上。
我可以使用悬停选项,将鼠标光标移至特定状态并查看自己的值。当我必须将地图导出为png时,其中不显示与状态相对应的值时,就会出现问题。
library(plotly)
df <- read.csv("50_us_state_names.csv")
df$hover <- with(df, paste(state, '<br>', "Weights", lbs))
l <- list(color = toRGB("white"), width = 2)
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showlakes = TRUE,
lakecolor = toRGB('white')
)
p <- plot_geo(df, locationmode = 'USA-states') %>%
add_trace(
z = ~total.exports, text = ~hover, locations = ~code,
color = ~total.exports, colors = 'YlOrRd'
) %>%
colorbar(title = "Weight in lbs") %>%
layout(
title = 'Weight wide breakdown<br>(Hover for breakdown)',
geo = g
)
p
我需要在地图上显示相应州的值total.exports