2016-01-21 5 views
9

Ich benutze Plotly, um Streudiagramm zu tun. Der Graph wird erzeugt auf meinem Konto, aber das Terminal meldet noch einen Fehler:KeyError: 'plotly_domain' bei der Verwendung von Plotly, um Streudiagramm in Python zu tun

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' 

Mein Code ist:

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

Jeder mir dabei helfen könnte? Vielen Dank.

+1

Machst du das in einem Ipython-Notebook? Wenn nicht, verwenden Sie den Befehl 'plot()' wie in der Antwort unten angegeben. – elsherbini

Antwort

27

Verwenden Sie py.plot anstelle von py.iplot. Probieren Sie es aus.

+2

Das funktioniert prächtig. 'iplot' arbeitet mit einem Jupyter-Notebook (früher IPython-Notebook). –

+0

Lol Ich fühle mich dumm –

Verwandte Themen