关闭 Matplotlib 中的左/底部轴刻度标记
matplotlibpythondata visualization更新于 2025/6/6 19:24:17
要关闭 matplotlib 中的左或底部轴刻度标记,我们可以对轴使用 length=0。
步骤
设置图形大小并调整子图之间和周围的填充。
使用 numpy 创建 x 和 y 数据点。
使用 plot() 方法绘制 x 和 y 数据点。
使用 tick_params() 方法和 length=0。
要显示图形,请使用 show() 方法。
示例
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 10) y = np.sin(x) plt.plot(x, y) plt.tick_params(axis='both', which='both', length=0) plt.show()
输出

相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

