1、错误描述
Traceback (most recent call last):
File "E:PyCharmhelperspydevpydev_run_in_console.py", line 52, in run_file
pydev_imports.execfile(file, globals, locals) # execute the script
File "E:PyCharmhelperspydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"
", file, 'exec'), glob, loc)
File "E:/PycharmProjects/cdk/venv/plotly/a.py", line 9, in <module>
y = [12,45,67,32,46,89,54,2,89]
TypeError: 'module' object is not callable
2、错误原因
import plotly;
import plotly.plotly as py;
import plotly.graph_objs as go;
plotly.tools.set_credentials_file(username='XXX',api_key='jkjdkja8798');
A = go.scatter(
x = [1,2,3,4,5,6,7,8,9],
y = [12,45,67,32,46,89,54,2,89]
)
data = [A];
py.iplot(data,filename='直线');
出现错误的地方是定义变量A,声明y坐标地方,错误原因是scatter,应该为Scatter
3、解决办法
将scatter修改为Scatter
import plotly;
import plotly.plotly as py;
import plotly.graph_objs as go;
plotly.tools.set_credentials_file(username='youhaidong',api_key='fl1sPa0GMIkz1R3Z1BHy');
A = go.Scatter(
x = [1,2,3,4,5,6,7,8,9],
y = [12,45,67,32,46,89,54,23,89]
)
data = [A];
py.plot(data,filename='直线');