- Import required modules
- After importing matplotlib, create a variable fig and equal it to plt.figure(). This will create an empty object. It will be empty initially and later it will be populated with data.
- After the creation of an empty object, we will add the axes to this figure. Since we are adding multiple axis to this figure, we need to add certain values to the axes such as left, bottom, width, height using a function add_axes(). The values of left, bottom, width and height inside add_axes() will range from 0 to 1.
- After creating the 1st axes, add the second axes. The values now will be smaller as compared to 1st axes because it is to be made inside the bigger one.
- Executing the lines without plotting any data will provide a figure with multiple axis and with no plots.
Below are some programs based on the above stepwise approach:
The below program depicts how to add multiple axes to a plot.
If we want to add multiple axes to a figure with a plotted graph, then we need to add some values of x and y demonstrated below and plot those points in the graph.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course