import matplotlib
#matplotlib.use('tkagg')
import numpy as np
import matplotlib.pyplot as plt
# print(matplotlib.matplotlib_fname())
print(matplotlib.get_backend())
x = np.arange(1,11)
y = 2 * x + 5
plt.title("Matplotlib demo")
plt.xlabel("x axis caption")
plt.ylabel("y axis caption")
plt.plot(x,y)
plt.show()
最近要用到matplotlib,但是如上plt.show()执行后并不显示也没报错。按网上大多数回答改了matplotlibrc,把
backend:Agg
改成了
backend:TkAgg
但是再打印matplotlib.get_backend()还是会输出QtAgg且不显示
以其他方式在文件最开始使用
import matplotlib
matplotlib.use('tkagg')
后matplotlib.get_backend()虽然会输出Tkagg,但还是不会显示但也不报错
真的想不出什么办法了,还望高人指点一二
试一下换一个matplotlib的版本?用3.5.1测试了一下是可以的