Is there a way to shift up the y-axis in matplotplib so that zero starts from "higher up"?

Question:

Answers:

You can place the ylim as slightly negative to "shift" your yaxis down slightly below zero. So long as you set a negative bottom ylim that is not as much as the intervals of you yticks, it shouldn’t populate a negative ytick on your graph,

With a slightly smaller bottom limit:

x = np.arange(0,1000)
y = np.arange(0,1000)

plt.plot(x,y)
plt.ylim(-50)

enter image description here

With a bottom ylim that equals the ytick interval:

x = np.arange(0,1000)
y = np.arange(0,1000)

plt.plot(x,y)
plt.ylim(-200)

enter image description here

Answered By: Michael S.
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.