-
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()三者的关系、用法及其代码尝试
最新推荐文章于 2025-03-06 08:48:33 发布