import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) fig.savefig('plot.png')
import numpy as np import matplotlib.pyplot as plt fig, axs = plt.subplots(2) x = np.arange(0, 2 * np.pi, 0.1) axs[0].plot(x, np.sin(x)) axs[1].plot(x, np.cos(x)) fig.savefig('sine_cosine.png')This example creates a figure with two subplots, each with a sine or cosine curve plotted. It then saves the figure as a PNG file named `sine_cosine.png`. Package: `matplotlib`