เพื่อให้ได้ตัวเลขปัจจุบันใน Matplotlib ของ Python เราสามารถใช้ plt.gcf().number.
ขั้นตอน
- ใช้ ตัวเลข(นับ) วิธีสร้างตัวเลขด้วย นับ หรือ ชื่อหน้าต่าง
- ในการนับจำนวนตัวเลข ใช้ plt.gcf().number.
ตัวอย่าง
from matplotlib import pyplot as plt
fig = plt.figure(3)
print("Number of figures: ", plt.gcf().number) ผลลัพธ์
Number of figures: 3