Home > Software engineering >  matplotlib: reduce empty space on axis
matplotlib: reduce empty space on axis

Time:10-18

The following code (obtained from output

What I'm trying to do is reduce the empty space on the y-axis, indicated here by the red bars:

enter image description here

How can I do this? Changing the height of the figure doesn't seem to help.

CodePudding user response:

One quick solution is to manually set the margins using

plt.margins(y=0) # no margin at all
plt.margins(y=1/len(df)) # equal margin
  • Related