Python中的 Matplotlib.axis.Axis.cla()函数
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。它是Python中用于二维数组图的惊人可视化库,用于处理更广泛的 SciPy 堆栈。
matplotlib.axis.Axis.cla()函数
matplotlib库的axis模块中的Axis.cla()函数用于清除该轴。
Syntax: Axis.cla(self)
Parameters: This method does not accepts any parameter.
Return value: This method does not returns any value.
下面的示例说明了 matplotlib.axis 中的 matplotlib.axis.Axis.cla()函数:
示例 1:
Python3
# Implementation of matplotlib function
from matplotlib.axis import Axis
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
# providing values to x and y
x = [8, 5, 11, 13, 16, 23]
y = [14, 8, 21, 7, 12, 15]
fig, ax = plt.subplots()
ax.plot(x, y)
ax.set_xlabel("X-axis")
ax.set_ylabel("Y-axis")
Axis.cla(ax.xaxis)
Axis.cla(ax.yaxis)
plt.title("Matplotlib.axis.Axis.cla()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
Python3
# Implementation of matplotlib function
import numpy as np
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
t = np.linspace(0.0, 2.0, 201)
s = np.sin(2 * np.pi * t)
fig, ax= plt.subplots()
ax.plot(t, s)
ax.grid(True)
ax.set_ylabel('y-axis', fontweight ='bold')
ax.set_xlabel('x-axis', fontweight ='bold')
Axis.cla(ax.yaxis)
plt.title("Matplotlib.axis.Axis.cla()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
输出:
示例 2:
Python3
# Implementation of matplotlib function
import numpy as np
from matplotlib.axis import Axis
import matplotlib.pyplot as plt
t = np.linspace(0.0, 2.0, 201)
s = np.sin(2 * np.pi * t)
fig, ax= plt.subplots()
ax.plot(t, s)
ax.grid(True)
ax.set_ylabel('y-axis', fontweight ='bold')
ax.set_xlabel('x-axis', fontweight ='bold')
Axis.cla(ax.yaxis)
plt.title("Matplotlib.axis.Axis.cla()\n\
Function Example", fontsize = 12, fontweight ='bold')
plt.show()
输出: