Matplotlib.pyplot.delaxes() in Python (original) (raw)

Last Updated : 21 Apr, 2020

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:

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

Python3 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:

Python3 1== `

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: