简体   繁体   English

如何在 Matplotlib 中更改轴刻度 label 速率

[英]How to change axis tick label rate in Matplotlib

I have a scatter graph and I would like to change the x and y tick rates.我有一个散点图,我想更改 x 和 y 滴答率。 Here is the graph I have:这是我的图表:

在此处输入图像描述

As you can see, the x value tick rate increases at a 0.02 rate.如您所见,x 值滴答率以 0.02 的速率增加。 I would like to change it to any other value.我想将其更改为任何其他值。 The same for the y axis. y轴也一样。

You can do that by supplying the tick positions you want with plt.xticks and plt.yticks .您可以通过plt.xticksplt.yticks提供所需的刻度位置来做到这一点。

For example, for a spacing of 0.05 in x, use例如,对于 x 中 0.05 的间距,使用

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

Same for the y axis. y轴也一样。 Here, np is numpy .这里, npnumpy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM