简体   繁体   中英

Python Y-axis scale normalization

I have set the y-axis limit using the below line of code.

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.

But is there any way I can normalize the above dividing by 32 to display 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,...

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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