UserWarning: Matplotlib is currently using pgf, which is a non-GUI backend, so cannot show the figure.
plt.show()
将 siunitx Latex 包导入 Python画图时无法在图形界面显示
因为导入了代码行:
mpl.use("pgf")
因为 pgf
不支持 plt.show()
,所以无法在图形界面显示
可以将 plt.show()
去掉后,在程序末尾加上
plt.savefig("f.png")
或
plt.savefig("f.pdf")
将图片保存下来再打开。