matplotlib.pyplot.cla()函数

您所在的位置:网站首页 cla起什么作用 matplotlib.pyplot.cla()函数

matplotlib.pyplot.cla()函数

2024-07-10 01:10| 来源: 网络整理| 查看: 265

matplotlib.pyplot.cla()函数

Matplotlib是Python中的一个库,它是NumPy库的数值-数学扩展。Pyplot是一个基于状态的Matplotlib模块接口,该模块提供了一个类似matlab的接口。Pyplot中可以使用的绘图有直线图、轮廓图、直方图、散点图、三维图等。

matplotlib.pyplot.cla()函数

使用matplotlib库pyplot模块中的cla()函数清除当前轴。

语法:

matplotlib.pyplot.cla()

下面的例子演示了matplotlib.pyplot.cla()函数在matplotlib.pyplot中的作用:

示例1 # Implementation of matplotlib function    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()

输出:

matplotlib.pyplot.cla()函数

示例2 # Implementation of matplotlib function 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()

输出:

matplotlib.pyplot.cla()函数



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3