我想用Python绘制一个给定的图形,但是这个图根本没有显示出来。我使用以下代码:
import pylab as p
C = [1,2,3,4]
S = [10, 20, 30, 10]
p.plot(C,S)
p.show()我怀疑这是因为我在Wayland中使用了OpenSUSE。有没有人知道一个解决办法,或者如何用OpenSUSE绘图?
所有的帮助都将受到极大的感谢。
发布于 2018-09-25 14:36:33
在这个这里上有另一篇文章,ImportanceofBeingErnest给出了一个很好的答案,建议在 import matplotlib.pyplot as plt之前使用import matplotlib; matplotlib.use("TkAgg") 。您可以在matplotlib站点上的后端上找到更多信息。您可能仍然需要安装相应的python到工具箱包,例如。python和python3-tk,或者尝试已经安装的后端。例如,qt5agg提供了一个交互配置一些图形参数的选项。
发布于 2019-02-02 00:56:21
使用Python3.6在Tumble杂草中
open软件管理选择python3-matplotlib,我选择python3-matplotlib-tk作为后端,然后安装
安装:- python3-Cycler python3-kiwisolver python 3-matplotlib python 3-matplotlib-tk python 3-numpy python 3-olefile python 3-Pillow python 3-python-dateutil python3-pytz
在python脚本中使用:- import matplotlib matplotlib.use('TkAgg')导入matplotlib.pyplot作为plt导入numpy作为np
为我工作。
https://stackoverflow.com/questions/52417791
复制相似问题