KeyError: 'plotly_domain' when using plotly to do scatter plot in python

元气小坏坏 提交于 2019-12-06 16:36:45

问题


I'm using plotly to do scatter plot. The graph is generated on my account but the terminal still reports an error:

Traceback (most recent call last):
File "IEORE4709HW1.py", line 106, in <module>
py.iplot(data, filename='basic-scatter')
File "/Library/Python/2.7/site-packages/plotly/plotly/plotly.py", line 175, in iplot
return tools.embed(url, **embed_options)
File "/Library/Python/2.7/site-packages/plotly/tools.py", line 412, in embed
!= session.get_session_config()['plotly_domain']):
KeyError: 'plotly_domain'

My code is:

import urllib2
import numpy as np

import plotly.plotly as py
py.sign_in('halblooline', 'j90503v8gq')
import plotly.graph_objs as go
import numpy as np

N = 1000
random_x = np.random.randn(N)
random_y = np.random.randn(N)

# Create a trace
trace = go.Scatter(
    x = random_x,
    y = random_y,
    mode = 'markers'
)

data = [trace]

# Plot and embed in ipython notebook!
py.iplot(data, filename='basic-scatter')

# or plot with: plot_url = py.plot(data, filename='basic-line')

Any one could help me with this? Thank you very much.


回答1:


use py.plot instead of py.iplot. Have a try.



来源:https://stackoverflow.com/questions/34929778/keyerror-plotly-domain-when-using-plotly-to-do-scatter-plot-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!