KeyError:'plotly_domain'在使用plotly在python中进行散点图时

时间:2016-01-21 16:58:38

标签: python plot plotly keyerror

我正在使用情节来做散点图。该图表是在我的帐户中生成的,但终端仍然报告错误:

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'

我的代码是:

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

任何人都可以帮我这个吗?非常感谢你。

1 个答案:

答案 0 :(得分:58)

使用py.plot而不是py.iplot。试一试。