Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Python

Cách lấy số thứ tự figure hiện tại trong Matplotlib Python?

Để lấy số thứ tự figure hiện tại trong Matplotlib Python, ta dùng plt.gcf().number.

Các bước

  • Dùng figure(count) để tạo nhiều figure với count hoặc tên cửa sổ.
  • Lấy số lượng figure bằng plt.gcf().number.

Ví dụ

from matplotlib import pyplot as plt
fig = plt.figure(3)
print("Number of figures: ", plt.gcf().number)

Kết quả

Number of figures: 3