[英]Python matplotlib: figure can not update after show
以下代码工作正常:
Python 3.8.2 (default, Apr 8 2020, 14:31:25)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> fig.suptitle("Empty figure")
Text(0.5, 0.98, 'Empty figure')
>>> fig.show()
但是,如果我在show
之后设置字幕(或做任何其他事情),即使我再次运行show()
,它也不起作用。
Python 3.8.2 (default, Apr 8 2020, 14:31:25)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> fig = plt.figure()
>>> fig.show()
>>> fig.suptitle("Empty figure")
Text(0.5, 0.98, 'Empty figure')
>>> fig.show()
我是 python 的新手。 有人可以帮我吗?
在 matplotlib 中, .show()
方法本质上旨在阻止代码在调用后的任何进一步执行,直到所示图关闭。 除非您在调用.ion()
.show()
交互模式,否则还有一个可选的 boolean 参数要传入以关闭阻塞功能:
plt.show(block=False)
在此处查看文档: https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.show.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.