How to Add Axes to a Figure in Matplotlib with Python? Last Updated : 02 Dec, 2020 Comments Improve Suggest changes Like Article Like Report Matplotlib is a library in Python used to create figures and provide tools for customizing it. It allows plotting different types of data, geometrical figures. In this article, we will see how to add axes to a figure in matplotlib. We can add axes to a figure in matplotlib by passing a list argument in the add_axes() method. Syntax: matplotlib.pyplot.figure.add_axes(rect) Parameters: rect: This parameter is the dimensions [xmin, ymin, dx, dy] of the new axes. It takes the below elements as arguments in the list: xmin: Horizontal coordinate of the lower left corner.ymin: Vertical coordinate of the lower left corner.dx: Width of the subplot.dy: Height of the subplot. Returns: This method return the axes class depends on the projection used. Below are some programs which depict how to add axes to a figure in matplotlib: Example 1: Python3 # Importing library import matplotlib # Create figure() objects # This acts as a container # for the different plots fig = matplotlib.pyplot.figure() # Creating axis # add_axes([xmin,ymin,dx,dy]) axes = fig.add_axes([0.5, 1, 0.5, 1]) # Depict illustration fig.show() Output: Example 2: Python3 # Importing library import matplotlib # Create figure() objects # This acts as a container # for the different plots fig=matplotlib.pyplot.figure() # Creating two axes # add_axes([xmin,ymin,dx,dy]) axes=fig.add_axes([0,0,2,2]) axes1=fig.add_axes([0,1,2,2]) # Depict illustration fig.show() Output: Example 3: Python3 # Import libraries import matplotlib import numpy # Create figure() objects # This acts as a container # for the different plots fig = matplotlib.pyplot.figure() # Generate line graph x = numpy.arange(0, 1.414*2, 0.05) y1 = numpy.sin(x) y2 = numpy.cos(x) # Creating two axes # add_axes([xmin,ymin,dx,dy]) axes1 = fig.add_axes([0, 0, 1, 1]) axes1.plot(x, y1) axes2 = fig.add_axes([0, 1, 1, 1]) axes2.plot(x, y2) # Show plot plt.show() Output: Comment More infoAdvertise with us Next Article How to Add Axes to a Figure in Matplotlib with Python? A amnindersingh1414 Follow Improve Article Tags : Machine Learning AI-ML-DS Python-matplotlib python Practice Tags : Machine Learningpython Similar Reads How to Add Multiple Axes to a Figure in Python In this article, we are going to discuss how to add multiple axes to a figure using matplotlib in Python. We will use the add_axes() method of matplotlib module to add multiple axes to a figure. Step-by-step Approach: Import required modulesAfter importing matplotlib, create a variable fig and equal 3 min read Matplotlib.figure.Figure.add_axes() in Python Matplotlib is a library in Python and it is a numerical â mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top-level containers for all p 2 min read Matplotlib.axes.Axes.set_figure() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read How to add a grid on a figure in Matplotlib ? Matplotlib library is widely used for plotting graphs. In many graphs, we require to have a grid to improve readability. Grids are created by using grid() function in the Pyplot sublibrary. In this article, we will see how to add grid in Matplotlb. Add a Grid on a Figure in MatplotlibBelow are the w 3 min read Matplotlib.axes.Axes.get_figure() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute. 2 min read Matplotlib.axis.Tick.set_figure() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Tick.set_figure() Function The Tick.set_figure() function in ax 2 min read Matplotlib.figure.Figure.add_subplot() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot 2 min read How to Create Subplots in Matplotlib with Python? Matplotlib is a widely used data visualization library in Python that provides powerful tools for creating a variety of plots. One of the most useful features of Matplotlib is its ability to create multiple subplots within a single figure using the plt.subplots() method. This allows users to display 6 min read Matplotlib.axis.Axis.set_figure() function in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack. Matplotlib.axis.Axis.set_figure() Function The Axis.set_figure() function in ax 2 min read Matplotlib.figure.Figure.delaxes() in Python Matplotlib is a library in Python and it is numerical â mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot 2 min read Like