-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Closed
Labels
Milestone
Description
Bug summary
subplots() adds axes in row-major order, but subfigures() add subfigures in column-major order
Code for reproduction
from pylab import *
f = figure()
f.subplots(3, 3)
for i, ax in enumerate(f.axes): ax.set_title(i)
savefig("/tmp/subplots.png")
f = figure()
f.subfigures(3, 3)
for i, sf in enumerate(f.subfigs): sf.suptitle(i)
savefig("/tmp/subfigures.png")
Actual outcome
Expected outcome
Subfigures are added in row-major axis, per standard numpy defaults.
Additional information
In practice this should rarely matter, as the subfigures don't overlap so drawing order should be irrelevant... perhaps unless some artists are positioned beyond the subfigure edge and not clipped.
The behavior directly arises from the iteration in subfigures:
sfarr = np.empty((nrows, ncols), dtype=object)
for i in range(ncols):
for j in range(nrows):
sfarr[j, i] = self.add_subfigure(gs[j, i], **kwargs)
Operating system
macOS
Matplotlib Version
3.10.0.dev233+ga833d99e46
Matplotlib Backend
qtagg
Python version
3.12
Jupyter version
no
Installation
git checkout