asdfyxcvqwer
asdfyxcvqwer

Reputation: 31

Setting the space of first x tick (0) and y axis

I want the first x tick (0) nearer to the y axis. I tried setting xlim, but I don't want to have the first x tick where the axes are crossing. Like just half the space between the y axis and the first x tick. I didn't find an solution, maybe you can help me.

This is a minimal reproducible example:

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()

Upvotes: 2

Views: 2017

Answers (1)

Sheldore
Sheldore

Reputation: 39042

You can use plt.margins to specify the margins for x and y axis spearately.

plt.margins(x=0.02)

enter image description here

Upvotes: 4

Related Questions