[英]Why am I getting UserWarning: Matplotlib is currently using ps, which is a non-GUI backend, so cannot show the figure
This is not in a jupyter
notebook so this is not a duplicate of this question , but my code is: 这不在
jupyter
笔记本中,因此这不是此问题的重复项 ,但是我的代码是:
from gluoncv import model_zoo, data, utils
from matplotlib import pyplot as plt
...
plt.show()
The error I'm getting is: 我得到的错误是:
/figure.py:445: UserWarning: Matplotlib is currently using ps, which is a non-GUI backend, so cannot show the figure.
% get_backend())
I created a repl at https://repl.it/@shamoons/WelloffHarmfulMineral 我在https://repl.it/@shamoons/WelloffHarmfulMineral创建了一个repl
If it matters, I'm using OS X. What do I need to do to get the image to show? 如果有问题,我正在使用OSX。我需要做些什么才能显示图像?
matplotlib.use('PS')
and plt.show()
are mutually exclusive. matplotlib.use('PS')
和plt.show()
是互斥的。 You need to decide: 您需要决定:
matplotlib.use('PS')
. matplotlib.use('PS')
。 PS
backend? PS
后端吗? This seems unlikely, because there is rarely a reason to set the backend to something non-interactive unless working on a server. plt.show()
by plt.savefig("filname.ps")
. plt.show()
替换为plt.savefig("filname.ps")
。 You can use 您可以使用
matplotlib.use("TkAgg")
instead of 代替
matplotlib.use("PS")
when developing on MacOS. 在MacOS上进行开发时。
Please note that the import should be before importing plt
, like this: 请注意,导入应在导入
plt
之前进行,如下所示:
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.