獲取 Matplotlib 中圖形列表


若要獲取 matplotlib 中的圖形列表,我們可以執行以下步驟:

  • 使用 figure() 方法建立新圖形或啟用現有圖形。建立 x 個圖形,即 x=3。

  • 要獲取圖形列表,請使用 plt.get_fignums() 方法。

示例

from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
plt.figure()
plt.figure()
plt.figure()
print("Number of figures created: ", len(plt.get_fignums()))
plt.show()

輸出

Number of figures created: 3

更新於:2021 年 4 月 9 日

1K+ 瀏覽

開啟你的 職業

完成課程以獲得認證

開始
廣告
© . All rights reserved.