繁体   English   中英

Plotly R无法与Jupyter笔记本一起使用

[英]Plotly R not working with Jupyter notebook

我想在我的Jupyter笔记本中合并Plotly图,但是在尝试显示图时出现404错误:

错误

根据这篇文章

import sys; print(sys.executable)

给我这个Python的位置。 我在该目录中有两个Pandoc文件,以及Plotly页面上提到的所有所需文件。

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

我也尝试过重新安装Anaconda和Pandoc,但仍然出现此错误。 有什么想法吗?

你有一个阴谋户口吗? 您可能需要使用类似以下内容的内容在笔记本中登录它:

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')

我在MacOS中也有同样的问题。 在控制台中,可以看到它正在寻找.html.embed,但是创建的文件是.html。 我尝试过,1)重新安装Pandocs 2)由于软件包pbdZMQ无法正确安装,不得不重新安装Cairo。

这是我所做的解决方法,

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)

这不是最好的解决方案,但暂时对我有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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