简体   繁体   中英

Matplotlib ticks at y-axis

I have a problem concerning ticks and labels on my graph, that seems to be a really basic question, but i simply cannot figure it out:

I need to start the y-axis of my graph at 1 instead of 0. That is, what i achive with

ax = plt.gca()
ax.set_ylim([1, 250]) #y-axis limits

My problem now is to set the right ticks and their labels.

So i want to start my graph with 1 at the very bottom, followed by 50, 100, 150, 200, 250.

I have played around a lot with yticks, eg:

import matplotlib.pyplot as plt

ticks=[1, 50, 100, 150, 200, 250]
labels=[1, 50, 100, 150, 200, 250]

plt.yticks(ticks, [labels])

but i cannot figure out, what iam doing wrong.

Thx in advance!

Of course i tried that before @ImportanceOfBeingErnest.

Thanks to your input, i figured out, that not the "yticks" line was the problem, but the

plt.yscale("linear")

in the end of my code. Removing this line, it works as expected.

Thank you!

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