Plotly map does not display in viewer pane

plotly
viewer

#1

Continuing from: Creating a map by R-Studio

Thank you! Jcblum,

I run the code by RGui and got the map successfully, but why it doesn't work in R-Studio?


Creating a map by R-Studio
#2

When you say it doesn't work, what exactly is not working? (I ran the code above in RStudio and everything worked as expected)


#3

I just got the measure bar, the map doesn't show up.


#4

@Visiting, have you tried hovering over the area where the map should be and clicking on the 'white area'.

I know, at least for me, that when I'm using plotly I usually have to click the white space where the map should be for the image to show up.


#5

@Hlynur I did, no map show up, only the measure bar in the viewer window. Thanks.


#6

I've split this out into a new topic, since it seems to be a separate issue. Can you confirm a few things?

  1. What is the exact code you are running?

  2. Some information about your system would be helpful:

    • The output of running sessionInfo() after you've run the code that makes the map
    • The output of running rstudioapi::versionInfo()

#7

The code is exact the same, listed below:

library(plotly)
mh <- data.frame(
  rank = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
           19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
           31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
           43, 44, 45, 46, 47, 48, 49, 50, 51),
  state = c("CT", "MA", "VT", "SD", "MN", "NJ", "IA", "ND", "PA", "ME",
            "DE", "NY", "AK", "MD", "IL", "HI", "MI", "DC",
            "KY", "NH", "KS", "NM", "CA", "OK", "CO", "OH",
            "NE", "FL", "WY", "WA", "MO", "TX", "NC", "GA",
            "WI", "RI", "SC", "VA", "MT", "UT", "TN", "LA",
            "WV", "MS", "IN", "AL", "AR", "ID", "OR", "AZ",
            "NV")
)

plot_ly(
  type = "choropleth",
  locations = mh$state,
  locationmode = "USA-states",
  z = mh$rank
) %>%
  layout(geo = list(scope = "usa"))

scale%20bar
Here is the output, only scale bar displayed in the viewer window, no map.

Here is sessionInfo()

########################################################
R version 3.5.0 (2018-04-23)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252 
[2] LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252
[4] 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] bindrcpp_0.2.2 plotly_4.8.0   ggplot2_3.0.0 

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.17      bindr_0.1.1       magrittr_1.5      tidyselect_0.2.4 
 [5] munsell_0.4.3     xtable_1.8-2      viridisLite_0.3.0 colorspace_1.3-2 
 [9] R6_2.2.2          rlang_0.2.1       httr_1.3.1        plyr_1.8.4       
[13] dplyr_0.7.5       tools_3.5.0       grid_3.5.0        data.table_1.11.4
[17] gtable_0.2.0      withr_2.1.2       crosstalk_1.0.0   htmltools_0.3.6  
[21] yaml_2.1.19       lazyeval_0.2.1    assertthat_0.2.0  digest_0.6.15    
[25] tibble_1.4.2      shiny_1.1.0       later_0.7.3       tidyr_0.8.1      
[29] purrr_0.2.5       promises_1.0.1    htmlwidgets_1.2   mime_0.5         
[33] glue_1.2.0        compiler_3.5.0    pillar_1.2.3      scales_0.5.0     
[37] jsonlite_1.5      httpuv_1.4.3      pkgconfig_2.0.1  
> rstudioapi::versionInfo()
############################################################
$`citation`

To cite RStudio in publications use:

  RStudio Team (2016). RStudio: Integrated Development for R. RStudio,
  Inc., Boston, MA URL http://www.rstudio.com/.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {RStudio: Integrated Development Environment for R},
    author = {{RStudio Team}},
    organization = {RStudio, Inc.},
    address = {Boston, MA},
    year = {2016},
    url = {http://www.rstudio.com/},
  }

$`mode`
[1] "desktop"

$version
[1] ‘1.1.383’

Thank you!


#8

Hmm, so I cannot replicate this on RStudio Cloud (R 3.5.0, RStudio Server Pro 1.2.747.3) — everything works fine there as you can see in this shared project:
https://rstudio.cloud/project/51112

However, on a system that's running R 3.3.3 and RStudio 1.1.447, I can replicate the problem. No map, just the scale bar. This is not a perfect analog for your situation, since you are running a substantially newer R and on a different OS than my old system.

I am noticing that your RStudio is not the current release (you have 1.1.383, while the current release is 1.1.456. There is also a preview release of 1.2 available (https://www.rstudio.com/products/rstudio/download/preview/) — running this would be close to the RStudio Cloud setup where we know the problem does not occur.

So perhaps try updating your RStudio to the preview release and see if that helps?


#9

Upgraded R-Studio to preview release of 1.2, now it works well.
Thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


#10

Great! Happy mapping :grin:


#11

A post was split to a new topic: Help creating a map


#12

This post was flagged by the community and is temporarily hidden.