这个错误是由于在调用 subplot 函数时使用了 sharex=Truesharey=True 参数,并且它们的值为布尔值而不是轴对象。解决方法是将 sharexsharey 参数设置为轴对象,例如:

ax1 = plt.subplot(211)
ax2 = plt.subplot(212, sharex=ax1, sharey=ax1)

这样就可以将第二个子图与第一个子图共享相同的 x 轴和 y 轴。

解决 Matplotlib 中 'TypeError: cannot create weak reference to 'bool' object' 错误

原文地址: https://www.cveoy.top/t/topic/n7M3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录