gpt4 book ai didi

python - matplotlib:子图重叠的 ylabels

转载 作者:太空宇宙 更新时间:2023-11-04 03:51:51 30 4
gpt4 key购买 nike

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

ylabels of subplots overlap

有什么方法可以将每个子图的极端 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:子图重叠的 ylabels,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20972033/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com