8000 flip subfigures axes to match subplots · matplotlib/matplotlib@a25c1bd · GitHub
[go: up one dir, main page]

Skip to content

Commit a25c1bd

Browse files
committed
flip subfigures axes to match subplots
1 parent 6e23101 commit a25c1bd

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/matplotlib/figure.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,9 +1583,9 @@ def subfigures(self, nrows=1, ncols=1, squeeze=True,
15831583
left=0, right=1, bottom=0, top=1)
15841584

15851585
sfarr = np.empty((nrows, ncols), dtype=object)
1586-
for i in range(ncols):
1587-
for j in range(nrows):
1588-
sfarr[j, i] = self.add_subfigure(gs[j, i], **kwargs)
1586+
for i in range(nrows):
1587+
for j in range(ncols):
1588+
sfarr[i, j] = self.add_subfigure(gs[i, j], **kwargs)
15891589

15901590
if self.get_layout_engine() is None and (wspace is not None or
15911591
hspace is not None):

lib/matplotlib/tests/test_figure.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,3 +1733,14 @@ def test_warn_colorbar_mismatch():
17331733
subfig3_1.colorbar(im3_2) # should not warn
17341734
with pytest.warns(UserWarning, match="different Figure"):
17351735
subfig3_1.colorbar(im4_1)
1736+
1737+
1738+
@check_figures_equal(extensions=['png'])
1739+
def test_subfigure_row_order(fig_test, fig_ref):
1740+
# Test that subfigures are drawn in row major order.
1741+
sf_arr_ref = fig_ref.subfigures(4, 3)
1742+
for i, sf in enumerate(sf_arr_ref.ravel()):
1743+
sf.suptitle(i)
1744+
fig_test.subfigures(4, 3)
1745+
for i, sf in enumerate(fig_test.subfigs):
1746+
sf.suptitle(i)

0 commit comments

Comments
 (0)
0