A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/matplotlib-axes-axes-remove-in-python/ below:

Matplotlib.axes.Axes.remove() in Python - GeeksforGeeks

Matplotlib.axes.Axes.remove() in Python

Last Updated : 12 Jul, 2025

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.

matplotlib.axes.Axes.remove() Function

The

Axes.remove() function

in axes module of matplotlib library is used to remove the artist from the figure if possible.

Syntax:
Axes.remove(self)

Below examples illustrate the matplotlib.axes.Axes.remove() function in matplotlib.axes:

Example 1: Python3
# Implementation of matplotlib function
import matplotlib.pyplot as plt

fig, axs = plt.subplots()
axs.plot([1, 2, 3])
axs.remove()

fig.suptitle('matplotlib.axes.Axes.remove()\
 function Example', fontweight ="bold")

plt.show()
Output: Example 2: Python3
# Implementation of matplotlib function
import matplotlib.pyplot as plt

fig, (axs, axs2) = plt.subplots(2, 1)
gs = axs2.get_gridspec()

axs.remove()
    
axbig = fig.add_subplot(gs[1:, -1])
axbig.annotate("Removed one Axes",
               (0.4, 0.5),
               xycoords ='axes fraction',
               va ='center')
 
fig.suptitle('matplotlib.axes.Axes.remove()\
 function Example', fontweight ="bold")
plt.show()
Output:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4