Python中的 Matplotlib.pyplot.isinteractive()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Pyplot是 Matplotlib 模块的基于状态的接口,它提供了一个类似 MATLAB 的接口。在 Pyplot 中可以使用各种图,包括线图、等高线图、直方图、散点图、3D 图等。
matplotlib.pyplot.isinteractive() 方法
matplotlib 库的 pyplot 模块中的isinteractive() 方法用于获取每次绘图命令后是否重绘。
Syntax: matplotlib.pyplot.isinteractive()
Parameters: This method does not accept any parameters.
Returns: This method returns whether to redraw after every plotting command or not.
下面的示例说明了 matplotlib.pyplot 中的 matplotlib.pyplot.isinteractive()函数:
示例 1:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 500)
y = np.sin(x**2)+np.cos(x)
plt.plot(x, y, label ='Line 1')
plt.plot(x, y - 0.6, label ='Line 2')
w = plt.isinteractive()
print("Is we can redraw after every plotting command : ",
str(w))
plt.title('matplotlib.pyplot.isinteractive() function \
Example', fontweight ="bold")
plt.show()
输出:
Is we can redraw after every plotting command : False
示例 2:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
t = np.arange(0.01, 5.0, 0.01)
s = np.exp(-t)
plt.plot(t, s)
plt.ylim(1, 0)
plt.ylabel('Display Y-axis Label', fontweight ='bold')
plt.grid(True)
w = plt.isinteractive()
print("Is we can redraw after every plotting command : ",
str(w))
plt.title('matplotlib.pyplot.isinteractive() function \
Example', fontweight ="bold")
plt.show()
输出:
Is we can redraw after every plotting command : False