1、错误描述
E:PycharmProjectscdkvenvScriptspython.exe E:/PycharmProjects/cdk/venv/plotly/b.py
Traceback (most recent call last):
File "E:/PycharmProjects/cdk/venv/plotly/b.py", line 14, in <module>
py.iplot(data,filename='柱状图');
File "E:PycharmProjectscdkvenvlibsite-packagesplotlyplotlyplotly.py", line 170, in iplot
return tools.embed(url, **embed_options)
File "E:PycharmProjectscdkvenvlibsite-packagesplotly ools.py", line 404, in embed
!= session.get_session_config()['plotly_domain']):
KeyError: 'plotly_domain'
Process finished with exit code 1
2、错误原因
import plotly;
import plotly.plotly as py;
import plotly.graph_objs as go;
plotly.tools.set_credentials_file(username='xxx',api_key='787889Pa0GMIkz1R3Z1BHy');
C = go.Bar(
x = [1,2,3,4,5,6,7,8],
y = [7889,5623,9856,1254,4878,5656,3562,7445]
)
data = [C];
py.iplot(data,filename='柱状图');
3、解决办法
在进行绘制图形时,需要调用plot()方法,而不是iplot()方法
import plotly;
import plotly.plotly as py;
import plotly.graph_objs as go;
plotly.tools.set_credentials_file(username='xxx',api_key='56895656GMIkz1R3Z1BHy');
C = go.Bar(
x = [1,2,3,4,5,6,7,8],
y = [7889,5623,9856,1254,4878,5656,3562,7445]
)
data = [C];
py.plot(data,filename='柱状图');