Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。 Pyplot是Matplotlib模塊的基於狀態的接口,該模塊提供了MATLAB-like接口。
matplotlib.pyplot.delaxes()函數
matplotlib庫的pyplot模塊中的delaxes()函數用於從其圖形中刪除Axes軸。
用法: matplotlib.pyplot.delaxes(ax=None)
參數:此方法接受以下描述的參數:
- ax:該參數是要刪除的軸。其默認值為無。
以下示例說明了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()
輸出:
相關用法
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Matplotlib.pyplot.delaxes() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。