import matplotlib.pyplot as plt
squares = [1,4,9,16,25]
fig,ax = plt.subplots()
ax.plot(squares)
plt.show()
运行上面的程序发现无法显示图像,用了几个小时总算改回来了
本文分为 (安装Ipython并查看后端)+(增添程序)两部分
(建议本文从后往前看,先增添程序然后运行,看能否成功,然后再安装Ipython)
打开Windows powershell , 之后pip install Ipython
安装成功后输入Ipython
再输入%pylab 查看显示的是 TkAgg 还是Agg
如果是Agg,在代码前写入
import matplotlib;matplotlib.use('TkAgg')
import matplotlib;matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
squares = [1,4,9,16,25]
fig,ax = plt.subplots()
ax.plot(squares)
plt.show()