我正在try 使用pyplot绘制一个简单的图形,例如:
import matplotlib.pyplot as plt
plt.plot([1,2,3],[5,7,4])
plt.show()
但该图没有出现,我收到以下消息:
UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
我在几个地方看到,必须使用以下方法更改matplotlib的配置:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
我这样做了,但随后收到一条错误消息,因为它找不到模块:
ModuleNotFoundError: No module named 'tkinter'
然后,我try 使用pip install tkinter
(在虚拟环境中)安装"tkinter",但它没有找到:
Collecting tkinter
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
我还应该提到,我使用虚拟环境在PyCharm Community Edition IDE上运行所有这些,并且我的操作系统是Linux/Ubuntu18.04.
I would like to know how I can solve this problem in order to be able to display the graph.