Open In App

Matplotlib.figure.Figure.get_axes() in Python

Last Updated : 12 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
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 elements.

matplotlib.figure.Figure.get_axes() method

The get_axes() method figure module of matplotlib library is used to get the list of axes in the Figure.
Syntax: get_axes(self) Parameters: This method does not accept any parameters. Returns: This method returns a list of axes in the Figure.
Below examples illustrate the matplotlib.figure.Figure.get_axes() function in matplotlib.figure: Example 1: Python3
# Implementation of matplotlib function
import matplotlib.pyplot as plt
from matplotlib.tri import Triangulation
from matplotlib.patches import Polygon
import numpy as np


xs = list([ 1, 2, 3, 4, 5, 6, 7, 8, 9])
ys = list([9, 8, 7, 6, 5, 4, 3, 2, 1])
        
fig = plt.figure()

ax = fig.add_subplot(111)
ax.plot(ys, xs)

fig.get_axes()[0].set_ylabel("Y label")
fig.get_axes()[0].set_xlabel("X label")


fig.suptitle('matplotlib.figure.Figure.get_axes()\
function Example\n\n', fontweight ="bold")

plt.show()
Output: Example 2: Python3
# Implementation of matplotlib function
import matplotlib.pyplot as plt
from matplotlib.tri import Triangulation
from matplotlib.patches import Polygon
import numpy as np


xs = list([ 1, 2, 3, 4, 5, 6, 7, 8, 9])
ys = list([9, 8, 7, 6, 5, 4, 3, 2, 1])
        
fig = plt.figure()

ax = fig.add_subplot(111)
ax.bar(ys, xs, width = 0.5, align ="center")

fig.get_axes()[0].set_ylabel("Number")
fig.get_axes()[0].set_xlabel("Values")


fig.suptitle('matplotlib.figure.Figure.get_axes()\
 function Example\n\n', fontweight ="bold")

plt.show()
Output:

Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy