plotly.R
plotly.R copied to clipboard
ggplotly not rendering in RStudio on Windows
I recently introduced ggplotly()
to my students, and several who use Windows machines reported that nothing was rendered when the following code was executed:
library(gapminder)
library(plotly)
p <- gapminder %>%
ggplot(aes(gdpPercap, lifeExp)) +
geom_point(aes(color = country), show.legend = FALSE)
ggplotly(p)
In several cases, they re-installed R (3.6.2) and the packages tidyverse
and plotly
, and even RStudio, without effect, and I'm not sure how to further troubleshoot what might be going on.
Same here but with Ubuntu 18.04.3 LTS. The problem started when I updated plotly to the latest version.
library(ggplot2)
ggplot(mtcars, aes(disp, mpg)) +
geom_point()
plotly::ggplotly()
Created on 2020-03-15 by the reprex package (v0.3.0)
Session info
devtools::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#> setting value
#> version R version 3.6.1 (2019-07-05)
#> os Ubuntu 18.04.3 LTS
#> system x86_64, linux-gnu
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/Argentina/Buenos_Aires
#> date 2020-03-15
#>
#> ─ Packages ──────────────────────────────────────────────────────────────
#> package * version date lib
#> assertthat 0.2.1 2019-03-21 [1]
#> backports 1.1.4 2019-04-10 [1]
#> callr 3.2.0 2019-03-15 [1]
#> cli 1.1.0 2019-03-19 [1]
#> colorspace 1.4-1 2019-03-18 [1]
#> crayon 1.3.4 2017-09-16 [1]
#> crosstalk 1.0.0 2016-12-21 [1]
#> curl 3.3 2019-01-10 [1]
#> data.table 1.12.6 2019-10-18 [1]
#> desc 1.2.0 2018-05-01 [1]
#> devtools 2.0.2 2019-04-08 [1]
#> digest 0.6.20 2019-07-04 [1]
#> dplyr 0.8.3 2019-07-04 [1]
#> evaluate 0.14 2019-05-28 [1]
#> fs 1.3.2 2020-03-05 [1]
#> ggplot2 * 3.3.0 2020-03-05 [1]
#> glue 1.3.1.9000 2019-08-20 [1]
#> gtable 0.3.0 2019-03-25 [1]
#> highr 0.8 2019-03-20 [1]
#> htmltools 0.3.6 2017-04-28 [1]
#> htmlwidgets 1.3 2018-09-30 [1]
#> httpuv 1.5.2 2019-09-11 [1]
#> httr 1.4.0 2018-12-11 [1]
#> jsonlite 1.6 2018-12-07 [1]
#> knitr 1.23 2019-05-18 [1]
#> labeling 0.3 2014-08-23 [1]
#> later 0.8.0 2019-02-11 [1]
#> lazyeval 0.2.2 2019-03-15 [1]
#> lifecycle 0.1.0 2019-08-01 [1]
#> magrittr 1.5 2014-11-22 [1]
#> memoise 1.1.0 2017-04-21 [1]
#> mime 0.7 2019-06-11 [1]
#> munsell 0.5.0 2018-06-12 [1]
#> pillar 1.4.2 2019-06-29 [1]
#> pkgbuild 1.0.3 2019-03-20 [1]
#> pkgconfig 2.0.2 2018-08-16 [1]
#> pkgload 1.0.2 2018-10-29 [1]
#> plotly 4.9.2 2020-02-12 [1]
#> prettyunits 1.0.2 2015-07-13 [1]
#> processx 3.3.0 2019-03-10 [1]
#> promises 1.0.1 2018-04-13 [1]
#> ps 1.3.0 2018-12-21 [1]
#> purrr 0.3.2 2019-03-15 [1]
#> R6 2.4.0 2019-02-14 [1]
#> Rcpp 1.0.2 2019-07-25 [1]
#> remotes 2.0.4 2019-04-10 [1]
#> rlang 0.4.1 2019-10-24 [1]
#> rmarkdown 1.13 2019-05-22 [1]
#> rprojroot 1.3-2 2018-01-03 [1]
#> scales 1.0.0 2018-08-09 [1]
#> sessioninfo 1.1.1 2018-11-05 [1]
#> shiny 1.3.2 2019-04-22 [1]
#> stringi 1.4.3 2019-03-12 [1]
#> stringr 1.4.0 2019-02-10 [1]
#> testthat 2.3.0 2019-11-05 [1]
#> tibble 2.1.3 2019-06-06 [1]
#> tidyr 1.0.0 2019-09-11 [1]
#> tidyselect 0.2.5 2018-10-11 [1]
#> usethis 1.5.0 2019-04-07 [1]
#> vctrs 0.2.0 2019-07-05 [1]
#> viridisLite 0.3.0 2019-09-23 [1]
#> webshot 0.5.1 2018-09-28 [1]
#> withr 2.1.2 2018-03-15 [1]
#> xfun 0.7 2019-05-14 [1]
#> xml2 1.2.0 2018-01-24 [1]
#> xtable 1.8-4 2019-04-21 [1]
#> yaml 2.2.0 2018-07-25 [1]
#> zeallot 0.1.0 2018-01-28 [1]
#> source
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> Github (tidyverse/glue@7ac044a)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.1)
#> Github (noamross/viridisLite@524c633)
#> CRAN (R 3.6.1)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#> CRAN (R 3.6.0)
#>
#> [1] /home/pao/R/x86_64-pc-linux-gnu-library/3.6
#> [2] /usr/local/lib/R/site-library
#> [3] /usr/lib/R/site-library
#> [4] /usr/lib/R/library
Please right-click -> "Inspect Element" and report any errors you see in the console tab
If anyone else encounters this please report the version of RStudio (as well as any console errors).
Note also that you can click the "Open in New Window" tab to open the plot in your default browser (please also let me know if it renders there)
Hello! I have the same error.
R Studio version: 1.1.463
Error log (repeated many times with slight variation):
This browser lacks typed array (Uint8Array) support which is required by buffer
v5.x. Use buffer
v4.x if you require old browser support. localhost:30787/session/viewhtml3e505b667c72/lib/plotly-main-1.52.2/plotly-latest.min.js:7
TypeError: undefined is not a constructor (evaluating 'Object.setPrototypeOf(e.prototype,Uint8Array.prototype)') localhost:30787/session/viewhtml3e505b667c72/lib/plotly-main-1.52.2/plotly-latest.min.js:7
ReferenceError: Can't find variable: Plotly
@xssokolova The current stable release of RStudio is 1.2.5033. If you can, upgrading will likely fix the issue. If you can't, you can also do this:
add_polyfill <- function(p) {
p <- plotly_build(p)
p$dependencies <- c(p$dependencies, plotly:::setPrototypeOfPolyfill())
p
}
plot_ly() %>%
add_polyfill()
I have a similar problem. It does plot the first plot but everthing after the first plot is omited. Same error when opening it in the browser. Also the CPU usage goes to 100% and doesnt go down till I close Rstudio.
Example:
plot_ly(midwest, x = ~percollege, color = ~state, type = "box")#works
plot_ly(midwest, x = ~percollege, type = "box") #empty viewer
plot_ly(midwest, x = ~percollege, color = ~state, type = "box")#empty viewer
@PhilippBuehler you might be experiencing https://github.com/ropensci/plotly/issues/1756 ... upgrading to RStudio preview may fix it https://github.com/ropensci/plotly/issues/1756#issuecomment-624212546
Hi,
I'm experiencing the same problem, and neither upgrading RStudio to current preview version nor the workaround you posted, @cpsievert , did work. Regarding the latter I actually had to change the code a bit, since p$dependencies
is a list, to the following:
add_polyfill <- function(p) {
p <- plotly_build(p)
p$dependencies[[length(p$dependencies) + 1]] <- plotly:::setPrototypeOfPolyfill()
p
}
From the structure of p
, I guess this should be correct?
Yet, when I inspect the missing plot in the resulting html, I find some error messages in the console, like e.g. the following:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /users/akubisch/My%20Documents/R/win-library/3.6/plotly/htmlwidgets/plotly.js was not found on this server.</p>
</body></html>
I'm under Windows 10, R 3.6.3, RStudio 1.3.959. Shall I try an RStudio daily instead?
Thanks a lot in advance!
I suggest you to update to the lastest RStudio version. I had a similar problem, and it turned out to be RStudio issue
Updating R-studio to the latest doesn't do the thing. (at least for me)
Try simply downgrade the ggplot2 version to 3.1.1; then re-install plotly.