user3169165
user3169165

Reputation: 31

matplotlib: ylabels of subplots overlapping

I have three subplots sharing x-axis. I need hspace between subplots to be 0.0, but then y-labels of subplots overlap.

ylabels of subplots overlap

Is there any way to move extreme y-labels of each subplot a little bit downwards or upwards (as I did manually in mspaint, on the right)?

Piotr

Upvotes: 2

Views: 1217

Answers (1)

M4rtini
M4rtini

Reputation: 13549

There is a dedicated ticker formater class exactly for this purpose.
http://matplotlib.org/api/ticker_api.html#matplotlib.ticker.MaxNLocator

from matplotlib.ticker import MaxNLocator
ax2.yaxis.set_major_locator(MaxNLocator(prune='upper'))  #remove highest label so it wont overlapp with stacked plot.

Edit: Actually this wont move them, just remove the overlapping ticks.

Upvotes: 2

Related Questions