import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax.plot([1,2,3,4],[1,4,2,3]) plt.show()
import matplotlib.pyplot as plt fig = plt.figure() ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8]) ax2 = fig.add_axes([0.2, 0.5, 0.4, 0.3])Here, we create a figure using plt.figure(). We create two Axes objects within this figure using fig.add_axes(). The first Axes object takes up 80% of the height and width of the figure and is positioned at 10% from the left and 10% from the bottom. The second Axes object takes up 30% of the height and 40% of the width of the figure and is positioned at 20% from the left and 50% from the bottom. Overall, add_axes() is a useful function for creating multiple Axes objects within a single figure or for positioning an Axes object within a figure. The package library used is matplotlib.