import matplotlib.pyplot as plt fig = plt.figure(figsize=(6, 4)) print(fig.get_size_inches())
array([6., 4.])
import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 100) y = np.sin(x) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y) fig.set_size_inches(8, 6) plt.show()In this example, we created a sinusoidal plot using NumPy and Matplotlib. We created a Figure object without specifying its size. After plotting the data, we use the set_size_inches method to change the Figure's size to 8 inches by 6 inches. Finally, we display the plot using the show method. In conclusion, the matplotlib.figure package library provides the Figure class, which allows us to create and save plots. The get_size_inches method is used to get the size of the Figure in inches. We can change the size of the Figure using the set_size_inches method.