I tried to run the Plotly R Chart in Jupyter from here and get:
404 Not Found error.
the code is as follows
library(plotly)
set.seed(123)
x <- rnorm(1000)
y <- rchisq(1000, df = 1, ncp = 0)
group <- sample(LETTERS[1:5], size = 1000, replace = T)
size <- sample(1:5, size = 1000, replace = T)
ds <- data.frame(x, y, group, size)
p <- plot_ly(ds, x = x, y = y, mode = "markers", group = group, size = size) %>%
layout(title = "Scatter Plot")
embed_notebook(p,file="/Jupyter Notebooks/plotlyJupyterHTML/test3.html")
The terminal has an error message:
404 GET /Jupyter%20Notebooks/plotlyJupyterHTML/test3.html.embed (::1) 6.51ms referer= http://localhost:8888/notebooks/Plotly%20%in%20R%20Testing-Copy1-ipynd
There is a file in the directory D:\\Jupyter Notebooks\\plotlyJupyterHTML\\test3.html
but not one with the additional extension .embed
.
The html file has the data and creates the correct chart when opened in firefox.
It seems the GET statement may have the wrong file name but I would appreciate any insight to get this to work.
Here is the session info:
Session info -------------------------------------------------------------------
Packages -----------------------------------------------------------------------
setting value
version R version 3.3.1 (2016-06-21)
system i386, mingw32
ui RTerm
language (EN)
collate English_United States.1252
tz America/New_York
date 2016-07-11
package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.3.1)
base64enc 0.1-3 2015-07-28 CRAN (R 3.3.0)
colorspace 1.2-6 2015-03-11 CRAN (R 3.3.1)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.1)
digest 0.6.9 2016-01-08 CRAN (R 3.3.1)
evaluate 0.9 2016-04-29 CRAN (R 3.3.1)
ggplot2 * 2.1.0 2016-03-01 CRAN (R 3.3.1)
gridExtra 2.2.1 2016-02-29 CRAN (R 3.3.1)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.1)
htmltools 0.3.5 2016-03-21 CRAN (R 3.3.1)
htmlwidgets 0.6 2016-02-25 CRAN (R 3.3.1)
httr 1.2.1 2016-07-03 CRAN (R 3.3.1)
IRdisplay 0.4.1 2016-07-09 Github (IRkernel/IRdisplay@8e24901)
IRkernel 0.6 2016-07-09 Github (IRkernel/IRkernel@8cdfe5e)
jsonlite 1.0 2016-07-01 CRAN (R 3.3.1)
magrittr 1.5 2014-11-22 CRAN (R 3.3.1)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.1)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.1)
pbdZMQ 0.2-3 2016-05-20 CRAN (R 3.3.1)
plotly * 3.6.0 2016-05-18 CRAN (R 3.3.1)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.1)
R6 2.1.2 2016-01-26 CRAN (R 3.3.1)
Rcpp 0.12.5 2016-05-14 CRAN (R 3.3.1)
repr 0.7 2016-05-13 CRAN (R 3.3.1)
scales 0.4.0 2016-02-26 CRAN (R 3.3.1)
stringi 1.1.1 2016-05-27 CRAN (R 3.3.0)
stringr 1.0.0 2015-04-30 CRAN (R 3.3.1)
tibble 1.1 2016-07-04 CRAN (R 3.3.1)
tidyr 0.5.1 2016-06-14 CRAN (R 3.3.1)
uuid 0.1-2 2015-07-28 CRAN (R 3.3.0)
viridis 0.3.4 2016-03-12 CRAN (R 3.3.1)
withr 1.0.2 2016-06-20 CRAN (R 3.3.1)
yaml 2.1.13 2014-06-12 CRAN (R 3.3.1)
I had the same issue in MacOS. This is the workaround I did,
p <- plot_ly(ds, x = x, y = y, mode = "markers", group = group, size = size)
htmlwidgets::saveWidget(as.widget(p), "index.html")
rawHTML <- paste(readLines("index.html"), collapse="\n")
display_html(rawHTML)
This is not the best solution, but for the time being this works for me.
That's because of that, probably: https://github.com/ropensci/plotly/commit/e80095358c19ef3032b611bd3a342504a163705a
It has been fixed already here: https://github.com/ropensci/plotly/commit/86e1e3607d58b3af2cf1c809f71c2536ce20a87d
You could wait, until it gets released to CRAN, or install developement version from github:
devtools::install_github("ropensci/plotly")
or
git clone https://github.com/ropensci/plotly
R CMD INSTALL plotly
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.