R Plotly等值线图空白

时间:2017-04-08 20:45:07

标签: r plotly

这是a dropbox link to my data csv

我试图在R中制作Plotly等值区域地图。我在Plotly示例页面中镜像代码如下:

wvs_ag = read.csv("wvs_ag.csv")

l = list(color = toRGB("grey"), width = 0.5)

g = list(
  showframe = FALSE,
  showcoastlines = FALSE,
  showland = TRUE,
  projection = list(type = 'Mercator')
)

p = plot_geo(wvs_ag) %>%
  add_trace(
    z = ~Agree_w, color = ~Agree_w, colors = 'Blues',
    text = ~Country_Code.p, locations = ~Country_Code.p, marker = list(line = l)) %>%
  colorbar(title = 'Agree_w') %>%
  layout(
    title = 'Title',
    geo = g
  )

然而,这会为我生成一张空白地图,只有右侧可见的比例。如何制作地图?

(旁注:我不知道Plotly接受的确切国家代码。我的原始数据有一组国家代码,所以我只是将它与Plotly示例页面中的数据合并,并使用他们的县代码。 )

编辑:这是sessioninfo()输出:

R version 3.3.3 (2017-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sp_1.2-4

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10      lattice_0.20-35   tidyr_0.6.1       viridisLite_0.2.0 digest_0.6.12    
 [6] dplyr_0.5.0       assertthat_0.1    grid_3.3.3        plyr_1.8.4        R6_2.2.0         
[11] jsonlite_1.3      gtable_0.2.0      DBI_0.6-1         magrittr_1.5      scales_0.4.1     
[16] httr_1.2.1        ggplot2_2.2.1     lazyeval_0.2.0    tools_3.3.3       htmlwidgets_0.8  
[21] purrr_0.2.2       munsell_0.4.3     yaml_2.1.14       base64enc_0.1-3   colorspace_1.3-2 
[26] htmltools_0.3.5   plotly_4.5.6      tibble_1.3.0   

0 个答案:

没有答案