目前正在尝试用python制作一些子脚本。这段代码昨天就开始工作了,现在我得到了“TypeError:‘tuple’对象不可调用”
奇怪的是,它允许我在命令栏中分别运行所有这些图形,但当我运行完整的代码时,它只绘制了其中两个图形,然后给出了这个错误。我必须重新启动内核才能重新开始绘图,否则我尝试绘图的任何东西都会给出这个答案
以下是我试图编写的代码:
plt.subplot(2,2,1)
plt.plot(x_axis, avg_ANK_ang[:,0], color='red', linewidth=1, linestyle = '--')
plt.fill_between(x_axis, avg_ANK_ang[:,0]-angANKnvf_err, avg_ANK_ang[:,0]+angANKnvf_err, alpha=0.5, facecolor='#FF9848')
plt.plot(x_axis, avg_ANK_ang[:,1], color='blue', linewidth=1)
plt.fill_between(x_axis, avg_ANK_ang[:,1]-angANKcvf_err, avg_ANK_ang[:,1]+angANKcvf_err, alpha=0.5, facecolor='#089FFF')
plt.xticks([])
seaborn.despine(left=True, bottom=True, right=True)
plt.ylabel("Ankle")
plt.title("Angle (deg)")
plt.subplot(2,2,3)
plt.plot(x_axis, avg_MTP_ang[:,0], color='red', linewidth=1, linestyle = '--')
plt.fill_between(x_axis, avg_MTP_ang[:,0]-angMTPnvf_err, avg_MTP_ang[:,0]+angMTPnvf_err, alpha=0.5, facecolor='#FF9848')
plt.plot(x_axis, avg_MTP_ang[:,1], color='blue', linewidth=1)
plt.fill_between(x_axis, avg_MTP_ang[:,1]-angMTPcvf_err, avg_MTP_ang[:,1]+angMTPcvf_err, alpha=0.5, facecolor='#089FFF')
seaborn.despine(left=True, bottom=True, right=True)
plt.plot = (x_axis, 0)
plt.ylabel("MTP")
plt.xlabel("% stance")
plt.subplot(2,2,2)
plt.plot(x_axis, avg_ANK_mom[:,0], color='red', linewidth=1, linestyle = '--')
plt.fill_between(x_axis, avg_ANK_mom[:,0]-momANKnvf_err, avg_ANK_mom[:,0]+momANKnvf_err, alpha=0.5, facecolor='#FF9848')
plt.plot(x_axis, avg_ANK_mom[:,1], color='blue', linewidth=1)
plt.fill_between(x_axis, avg_ANK_mom[:,1]-momANKcvf_err, avg_ANK_mom[:,1]+momANKcvf_err, alpha=0.5, facecolor='#089FFF')
plt.xticks([])
seaborn.despine(left=True, bottom=True, right=True)
plt.title("Moment (NM)")
plt.subplot(2,2,4)
plt.plot(x_axis, avg_MTP_mom[:,0], color='red', linewidth=1, linestyle = '--')
plt.fill_between(x_axis, avg_MTP_mom[:,0]-momMTPnvf_err, avg_MTP_mom[:,0]+momMTPnvf_err, alpha=0.5, facecolor='#FF9848')
plt.plot(x_axis, avg_MTP_mom[:,1], color='blue', linewidth=1)
plt.fill_between(x_axis, avg_MTP_mom[:,1]-momMTPcvf_err, avg_MTP_mom[:,1]+momMTPcvf_err, alpha=0.5, facecolor='#089FFF')
seaborn.despine(left=True, bottom=True, right=True)
plt.xlabel("% stance")
错误:
File "/Users/Laura/Box/NVF/Biomechanics data/Compile/compile.py", line 130, in <module>
plt.plot(x_axis, avg_ANK_mom[:,0], color='red', linewidth=1, linestyle = '--')
TypeError: 'tuple' object is not callable
另一件奇怪的事情是,它通常在给出错误之前绘制前两个图。(除非我将它们单独放在命令窗口中,否则前三个通常会打印)
这行代码就是问题所在。您已将
plt.plot
重新分配为元组变量,它不再是函数相关问题 更多 >
编程相关推荐