简体   繁体   中英

Plotly R not working with Jupyter notebook

I want to incorporate Plotly graphs in my Jupyter notebook but I'm getting a 404 error when I try to display a graph:

错误

According to this post

import sys; print(sys.executable)

Gives me this location for Python. I have the two Pandoc files in this directory as and all the files needed as mentioned on Plotly's page .

C:\Users\name\AppData\Local\Continuum\Anaconda3\python.exe

I have also tried reinstalling Anaconda and Pandoc but I'm still getting this error. Any thoughts?

Do you have a plotly account? You may need to login into it within your notebook with something similar to this:

import plotly
plotly.tools.set_config_file(plotly_domain='domain')


from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
import plotly.plotly as py
print __version__ # requires version >= 1.9.0
import plotly.graph_objs as go


init_notebook_mode() # run at the start of every ipython notebook to use plotly.offline
                     # this injects the plotly.js source files into the notebook
py.sign_in(username='xxxx', api_key='xxxx')

I have the same issue in MacOS. In the console, it can be seen that it's looking for .html.embed but the file which is created is .html. I have tried, 1) reinstalling Pandocs 2) Had to reinstall Cairo as package pbdZMQ was not getting installing properly.

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM