擅长:python、mysql、java
<p>调试的第一步是用<code>plt.savefig('foo.png')</code>替换<code>plt.show()</code>。如果可以,问题很可能出在后端:</p>
<pre><code>>>> import matplotlib
>>> matplotlib.get_backend()
'Qt4Agg'
</code></pre>
<p>尝试切换后端,看看这是否有帮助:
<a href="https://stackoverflow.com/questions/3285193/how-to-switch-backends-in-matplotlib-python">How to switch backends in matplotlib / Python</a></p>
<p>如果这也没有帮助,请确保您拥有所有依赖项(<a href="http://matplotlib.org/users/installing.html" rel="nofollow noreferrer">http://matplotlib.org/users/installing.html</a>)---我将从源代码重新安装。(<em>不</em><code>pip install matplotlib</code>)</p>