如何在 Matplotlib 中更改轴刻度标签率

时间:2021-04-18 13:59:20

标签: python matplotlib

我有一个散点图,我想更改 x 和 y 刻度率。这是我的图表:

enter image description here

如您所见,x 值刻度率以 0.02 的速率增加。我想将其更改为任何其他值。 y 轴也一样。

1 个答案:

答案 0 :(得分:1)

您可以通过使用 plt.xticksplt.yticks 提供您想要的刻度位置来做到这一点。

例如,对于 x 中 0.05 的间距,使用

step = 0.05
plt.xticks(np.arange(40.65, 40.85 + step, step))

y 轴相同。这里,npnumpy