import matplotlib.pyplot as plt fig, ax = plt.subplots() ax.plot([1, 2, 3], [4, 5, 6]) fig.delaxes(ax) plt.show()
import matplotlib.pyplot as plt fig, axs = plt.subplots(2, 2) # Delete the second row for ax in axs[1]: fig.delaxes(ax) plt.show()In this example, a new Figure and four Axes instances are created using the subplots() method. The second row of Axes is deleted using a for loop and the delaxes() method. The package library used in these examples is Matplotlib.