Matplotlib是Python中的一個庫,它是數字的-NumPy庫的數學擴展。 Pyplot是Matplotlib模塊的基於狀態的接口,該模塊提供了MATLAB-like接口。可在Pyplot中使用的各種圖線圖,輪廓圖,直方圖,散點圖,3D圖等。
matplotlib.pyplot.get_fignums()方法
matplotlib庫的pyplot模塊中的get_fignums()方法用於獲取現有圖形編號的列表。
用法:matplotlib.pyplot.get_fignums()
參數:此方法不接受任何參數。
返回:此方法返回現有圖形編號的列表。
以下示例說明了matplotlib.pyplot中的matplotlib.pyplot.get_fignums()函數:
範例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.get_fignums()
plt.text(2, 1.98,
"List of existing figure numbers:"
+ str(w),
fontsize = 12)
plt.title('matplotlib.pyplot.get_fignums() function\
Example', fontweight ="bold")
plt.show()
輸出:
範例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.get_fignums()
plt.text(0.9, 0.58,
"List of existing figure numbers:"
+ str(w),
fontsize = 12)
plt.title('matplotlib.pyplot.get_fignums() function\
Example', fontweight ="bold")
plt.show()
輸出:
注:本文由純淨天空篩選整理自SHUBHAMSINGH10大神的英文原創作品 Matplotlib.pyplot.get_fignums() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。