Thursday, September 4, 2025
HomeLanguagesMatplotlib.pyplot.delaxes() in Python

Matplotlib.pyplot.delaxes() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. Pyplot is a state-based interface to a Matplotlib module which provides a MATLAB-like interface.

matplotlib.pyplot.delaxes() Function

The delaxes() function in pyplot module of matplotlib library is used to remove the Axes ax from its figure.

Syntax: matplotlib.pyplot.delaxes(ax=None)

Parameters: This method accept the following parameters that are described below:

  • ax: This parameter is the axes which is to be removed. Its default value is None.

Below examples illustrate the matplotlib.pyplot.delaxes() function in matplotlib.pyplot:

Example #1:




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
     
# make an agg figure
fig, ax = plt.subplots()
ax.plot([1, 2, 3])
  
plt.delaxes()
  
plt.suptitle('matplotlib.pyplot.delaxes() function Example',
              fontweight ="bold")
  
plt.show()


Output:

Example #2:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
    
dt = 0.01
t = np.arange(0, 30, dt)
nse1 = np.random.randn(len(t))
r = np.exp(-t / 0.05)
    
cnse1 = np.convolve(nse1, r, mode ='same')*dt
    
s1 = np.cos(np.pi * t) + cnse1 + np.sin(2 * np.pi * 10 * t) 
    
fig, [ax1, ax2] = plt.subplots(2, 1)
ax1.plot(t, s1)
ax1.set_xlim(0, 5)
ax1.set_ylabel('value s1')
ax1.grid(True)
    
ax2.psd(s1, 256, 1./dt)
ax2.set_ylabel('PSD(db)')
ax2.set_xlabel('Frequency')
  
plt.delaxes(ax = ax1)
  
plt.suptitle('matplotlib.pyplot.delaxes() function Example',
              fontweight ="bold")
  
plt.show()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32263 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11857 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6696 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS