2016-01-21 27 views
9

Tôi đang sử dụng cốt truyện để vẽ đồ thị phân tán. Đồ thị được tạo ra trên tài khoản của tôi, nhưng nhà ga vẫn báo cáo một lỗi:KeyError: 'plotly_domain' khi sử dụng sơ đồ để vẽ đồ thị phân tán trong python

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' 

Mã của tôi là:

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

Bất kỳ ai có thể giúp tôi với điều này? Cảm ơn nhiều.

+1

bạn có đang thực hiện việc này trong sổ ghi chép ipython không? nếu không, sử dụng lệnh 'plot()' như được nêu trong câu trả lời dưới đây. – elsherbini

Trả lời

27

sử dụng py.plot thay vì py.iplot. Thử.

+2

Điều này hoạt động tuyệt vời. 'iplot' làm việc với một máy tính xách tay Jupyter (trước đây là máy tính xách tay IPython). –

+0

Lol Tôi cảm thấy ngu ngốc –

Các vấn đề liên quan