【报错】AttributeError: ‘NoneType’ object has no attribute ‘pyplot_show’
import matplotlib.pyplot as plt
plt.figure()
plt.plot(x, y, 'bo-')
plt.axis('equal')
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
plt.show()
- 查资料,看到让更新matplotlib,更新完问题没有解决
pip install --upgrade matplotlib
- 解决方法:加入下面两行代码后问题解决
- matplotlib.use(‘TkAgg’)
- import matplotlib.pyplot as plt
import matplotlib
matplotlib.use('TkAgg') # 或其他你常用的后端,如 'Qt5Agg'、'WXAgg' 等
import matplotlib.pyplot as plt
plt.figure()
plt.plot(x, y, 'bo-')
plt.axis('equal')
plt.xlabel('X')
plt.ylabel('Y')
plt.grid(True)
plt.show()