我正在学习Python,地址:https://plot.ly/python/offline/ 当我尝试这个例子时:
import plotly.plotly as py
fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
iplot(fig)
答案给了我这个错误:
---------------------------------------------------------------------------
PlotlyError Traceback (most recent call last)
<ipython-input-13-71d04f672671> in <module>()
1 import plotly.plotly as py
2
----> 3 fig = py.get_figure('https://plot.ly/~jackp/8715', raw=True)
4 iplot(fig)
D:\ProgramData\Anaconda2\lib\site-packages\plotly\plotly\plotly.pyc in get_figure(file_owner_or_url, file_id, raw)
407 "'{1}'."
408 "\nRun help on this function for more information."
--> 409 "".format(url, plotly_rest_url))
410 head = plotly_rest_url + "/~"
411 file_owner = url.replace(head, "").split('/')[0]
PlotlyError: Because you didn't supply a 'file_id' in the call, we're assuming you're trying to snag a figure from a url. You supplied the url, 'https://plot.ly/~jackp/8715', we expected it to start with 'https://plotly.your-company.com'.
Run help on this function for more information.
我不知道错误在哪里,我认为可能是url https://plotly.your-company.com坏了。
最佳答案
这是recommended获取凭据文件的方法。遵循教程时充分阅读示例总是有帮助的,正确设置您的环境也很重要。
plotly.tools.set_credentials_file(username='username-from-step-1', api_key='key-you-copied-from-step-2')
此行将授予您访问权限
编辑:iplot(fig)
如果您收到新错误,则仅适用于某些设置。尝试将该行替换为 py.plot(fig)
关于python - python plotly : PlotlyError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45879759/