plt 无响应 不显示图像 Pycharm does not show plot

Pycharm does not show plot

My solution

# cmd or conda
pip install pyqt5
import matplotlib
matplotlib.use('Qt5Agg')

it doesn't need to set

plt.show(block=True)

or

plt.interactive(False)

solution 1

import matplotlib.pyplot as plt
plt.show()

solution 2

plt.interactive(False)

I realize this is old but I figured I'd clear up a misconception for other travelers. Setting plt.pyplot.isinteractive() to False means that the plot will on be drawn on specific commands to draw (i.e. plt.pyplot.show()). Setting plt.pyplot.isinteractive() to True means that every pyplot (plt) command will trigger a draw command (i.e. plt.pyplot.show()). So what you were more than likely looking for is plt.pyplot.show() at the end of your program to display the graph.
As a side note you can shorten these statements a bit by using the following import command import matplotlib.pyplot as plt rather than matplotlib as plt.

solution 3

plt.show(block=True)

it works for me
but you need click to show next image

solution 4

import matplotlib
matplotlib.use('TkAgg')

It works for me too, but the problem is it will lead the error when you want to save figures in a loop.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容