如何在Matplotlib Python 2.6.6中设置X轴上的“步骤”? 要在Matplotlib Python中的图中设置X轴上的步骤,可以按照以下步骤进行: 步骤 创建数据点列表x。 使用 subplot() 方法将一个子图添加到当前图形中。 使用 xticks 和 ticklabels 设置 rotation=45 。 使用 show() 方法来显示图形。 例子 import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = [1, 2, 3, 4] y = [1.2, 1.9, 3.1, 4.2] plt.plot(x,y) ax1 = plt.subplot() ax1.set_xticks(x) ax1.set_xticklabels(["one", "two", "three", "four"], rotation=45) plt.show() PythonCopy 输出