matplotlib:子图的ylabels重叠

时间:2014-01-07 12:46:40

标签: python matplotlib

我有三个共享x轴的子图。我需要在子图之间的hspace为0.0,但是子图的y标签重叠。

ylabels of subplots overlap

有没有什么方法可以向下或向上移动每个子图的极端y标签(正如我在右边的mspaint中手动执行的那样)?

·彼得

1 个答案:

答案 0 :(得分:2)

为此目的,有一个专门的自动收报机类 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.

编辑: 实际上这不会移动它们,只需删除重叠的刻度。

相关问题