简体   繁体   English

Python Y轴比例尺归一化

[英]Python Y-axis scale normalization

I have set the y-axis limit using the below line of code. 我已使用以下代码行设置了y轴限制。

ax.yaxis.set_ticks(np.arange(0, 2047, 32))

When I plot using the above y-axis range, I am getting ticks at 0, 32, 64, 96,.....2047 and displaying the same. 当我使用上述y轴范围进行绘制时,我在0、32、64、96,..... 2047处显示刻度,并显示相同的刻度。

But is there any way I can normalize the above dividing by 32 to display 0, 1, 2, 3,...63? 但是有什么办法可以将上面的32除以显示0、1、2、3,... 63?

If I understood you correctly, you want the ticks to be placed at 0, 32, 64, 96, ... but the values (ticklabels) at the ticks to be displayed as 0, 1, 2, 3,... 如果我对您的理解正确,则希望将刻度线放置在0、32、64、96,...处,但将刻度线的值(刻度标签)显示为0、1、2、3,...。

To do so, first you can set the ticks as you are doing 为此,首先您可以在进行操作时设置刻度

ax.yaxis.set_ticks(np.arange(0, 2047, 32))

and then set the ticklabels as 然后将ticklabels设置为

ax.yaxis.set_ticklabels(np.arange(0, 64, 1))

Give it a try and let me know in the comments if this is what you want. 尝试一下,如果您要这样做,请在评论中让我知道。

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

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