-
plt.ion():将 figure 设置为交互模式,figure 不用 plt.show() 也可以显示。 -
plt.ioff():将 figure 设置为阻塞模式,也是 figure 的默认模式,figure 必须用 plt.show() 才能显示。 -
plt.show():显示所有的 figure(不管是阻塞模式的还是交互模式的)。若一个 figure 下一个 plt.show(),则只有关闭一个 figure,才会出现下一个 figure。若最后设置 plt.show(),则会显示设置的所有 figure。 -
运用代码加深理解:
4.1 交互模式下的尝试
import matplotlib.pyplot as plt plt.ion() plt.figure()4.2 阻塞模式下的尝试
import matplotlib.pyplot as plt # plt.ioff() plt.figure()4.3.1 混合模式下1
import matplotlib.pyplot as plt plt.figure() plt.ion() plt.figure()4.3.2 混合模式下2
import matplotlib.pyplot as plt plt.figure() plt.ion() plt.figure() plt.show()4.4 show下的模式
import matplotlib.pyplot as plt plt.figure() plt.show() plt.figure() plt.show()
Python -- matplotlib:plt.ion()、plt.ioff()、plt.show()三者的关系、用法及其代码尝试
Python Matplotlib:交互模式、阻塞模式与混合实践详解
最新推荐文章于 2024-04-08 09:45:44 发布
本文详细介绍了Matplotlib库中plt.ion(), plt.ioff()和plt.show()的使用,通过实例演示了交互模式、阻塞模式的切换以及它们在混合场景中的应用。读者将掌握如何在不同模式下创建和显示figure。
1739

被折叠的 条评论
为什么被折叠?



