Get the list of figures in Matplotlib



To get the list of figures in matplotlib, we can take the following steps −

  • Using figure() method, create a new figure, or activate an existing figure. Creating x figures, i.e., x=3.

  • To get the list of figures, use the plt.get_fignums() method.

Example

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()

Output

Number of figures created: 3

Advertisements