Friday, October 24, 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
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS