I have a problem regarding the starting point of y-axis. My data has some values that are almost below zero, but I dont want my graph to show negative values. I want my y-axis values to start from zero. Can I shift up the y-axis, still starting from zero?
Here is the current graph with plt.ylim(0, 1750):
And here it is without manually setting plt.ylim():
Here is the desired outcome:
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)
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)