JSowa
JSowa

Reputation: 10572

Check maximum and minimum ylim and set_ylim for all subplots

I have 7 subplots for each day of week. I want to have all of them the same size based on maximum range founded in plots and minimum range founded in plot.

I used something like this:

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

Is there any simple method setting automatically for all plots the same y ax limitation?

Upvotes: 0

Views: 201

Answers (1)

Diziet Asahi
Diziet Asahi

Reputation: 40667

You can pass sharey=True to subplots() so that all subplots share the same y limits

Upvotes: 1

Related Questions