[英]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.