Python中的 Matplotlib.pyplot.delaxes()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Pyplot是Matplotlib模块的基于状态的接口,它提供了一个类似 MATLAB 的接口。
matplotlib.pyplot.delaxes()函数
matplotlib 库的 pyplot 模块中的delaxes()函数用于从其图形中删除 Axes ax。
Syntax: matplotlib.pyplot.delaxes(ax=None)
Parameters: This method accept the following parameters that are described below:
- ax: This parameter is the axes which is to be removed. Its default value is None.
下面的示例说明了 matplotlib.pyplot 中的 matplotlib.pyplot.delaxes()函数:
示例 #1:
# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
# make an agg figure
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
plt.delaxes()
plt.suptitle('matplotlib.pyplot.delaxes() function Example',
fontweight ="bold")
plt.show()
输出:
示例 #2:
# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
dt = 0.01
t = np.arange(0, 30, dt)
nse1 = np.random.randn(len(t))
r = np.exp(-t / 0.05)
cnse1 = np.convolve(nse1, r, mode ='same')*dt
s1 = np.cos(np.pi * t) + cnse1 + np.sin(2 * np.pi * 10 * t)
fig, [ax1, ax2] = plt.subplots(2, 1)
ax1.plot(t, s1)
ax1.set_xlim(0, 5)
ax1.set_ylabel('value s1')
ax1.grid(True)
ax2.psd(s1, 256, 1./dt)
ax2.set_ylabel('PSD(db)')
ax2.set_xlabel('Frequency')
plt.delaxes(ax = ax1)
plt.suptitle('matplotlib.pyplot.delaxes() function Example',
fontweight ="bold")
plt.show()
输出: