TypeError: объект 'tuple' не может быть вызван при попытке создания участка в python - PullRequest
0 голосов
/ 01 апреля 2020

В настоящее время пытаюсь создать несколько сюжетов в 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

Другая странная вещь - обычно она строит первые два графика перед тем, как дать Ошибка. (Если я не добавлю их по отдельности в командное окно, первые три обычно будут отображаться)

1 Ответ

0 голосов
/ 01 апреля 2020
plt.plot = (x_axis, 0)

Эта строка кода является проблемой. Вы переназначили plt.plot на переменную кортежа, и она больше не является функцией.

...