检查所有子图的最大和最小ylim和set_ylim

问题描述 投票:0回答:1

我每周有7个子图。我希望基于地块中建立的最大范围和地块中建立的最小范围,使它们的大小相同。

我用过这样的东西:

fig, ax = plt.subplots(4, 2)

min_ylim = math.inf
max_ylim = 0

#...
#iterate over ax plots, draw a plot and check ylim
#...

plt.setp(ax, ylim=(min_ylim, max_ylim)) #apply to all subplots

是否为所有图自动设置了相同的y轴限制的简单方法?

python matplotlib
1个回答
0
投票

您可以将sharey=True传递给subplots(),以便所有子图共享相同的y限制

© www.soinside.com 2019 - 2024. All rights reserved.