Matplotlib.pyplot.cla() in Python (original) (raw)
Last Updated : 19 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. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, etc.
matplotlib.pyplot.cla() Function
The cla() function in pyplot module of matplotlib library is used to clear the current axes.
Syntax:
matplotlib.pyplot.cla()
Below examples illustrate the matplotlib.pyplot.cla() function in matplotlib.pyplot:
Example 1:
import
matplotlib.pyplot as plt
plt.plot([
1
,
2
,
3
,
4
], [
16
,
4
,
1
,
8
])
plt.cla()
plt.title(
'matplotlib.pyplot.cla Example'
)
plt.show()
Output:
Example 2:
import
numpy as np
import
matplotlib.pyplot as plt
t
=
np.linspace(
0.0
,
2.0
,
201
)
s
=
np.sin(
2
*
np.pi
*
t)
fig, [ax, ax1]
=
plt.subplots(
2
,
1
)
ax.set_ylabel(
'y-axis'
)
ax.plot(t, s)
ax.grid(
True
)
ax1.set_ylabel(
'y-axis'
)
ax1.set_xlabel(
'x-axis'
)
ax1.plot(t, s)
ax1.grid(
True
)
ax1.cla()
fig.suptitle(
'matplotlib.pyplot.cla Example'
)
plt.show()
Output:
Similar Reads
- Matplotlib.pyplot.clf() 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. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 1 min read
- Matplotlib.pyplot.gca() in Python Matplotlib is a library in Python and it is a numerical - mathematical extension for the NumPy library. Pyplot is a state-based interface to a Matplotlib module that provides a MATLAB-like interface.  matplotlib.pyplot.gca() Function The gca() function in pyplot module of matplotlib library is used 2 min read
- Matplotlib.pyplot.clim() 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. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 2 min read
- matplotlib.pyplot.clabel() in Python Contour plots or Level plots are a way to display a three-dimensional surface on a two-dimensional plane. It graphs as contours as one output variable z and two predictor variables x and y on the y-axis. Often such contours are also known as z-slices.The clabel() method in mathplotlib.pyplot is used 4 min read
- Matplotlib.pyplot.cool() 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.cool() Function The cool() function in pyplot module of matplotlib library is used to s 2 min read
- Matplotlib.pyplot.csd() 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.csd() Function The csd() function in pyplot module of matplotlib library is used to plo 3 min read
- Matplotlib.pyplot.gci() 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. There are various plots which can be used in Pyplot are Line Plot, Contour, Histogram, Scatter, 3D Plot, 2 min read
- Matplotlib.pyplot.gcf() in Python Matplotlib is an amazing visualization library in Python for 2D plots of arrays. Matplotlib is a multi-platform data visualization library built on NumPy arrays and designed to work with the broader SciPy stack. matplotlib.pyplot.gcf() matplotlib.pyplot.gcf() is primarily used to get the current fi 2 min read
- Matplotlib.pyplot.close() in Python Matplotlib close() function in pyplot module of the matplotlib library is used to close a figure window. This function is designed to close a figure window or a set of figure windows. When called without any arguments, it closes the currently active figure. Alternatively, we can pass a figure number 3 min read
- Matplotlib.pyplot.draw() 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.draw() Function The draw() function in pyplot module of matplotlib library is used to r 1 min read