我有三个共享 x 轴的子图。我需要子图之间的 hspace 为 0.0,但子图的 y 标签会重叠。
有没有办法将每个子图的极端 y 标签向下或向上移动一点(就像我在右侧的 mspaint 中手动所做的那样)?
皮奥特尔
最佳答案
有一个专用的股票代码格式化程序类正是用于此目的。
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.
编辑: 实际上这不会移动它们,只需删除重叠的刻度即可。
关于python - matplotlib:子图重叠的 y 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20972033/