Skip to content

Commit 3a58953

Browse files
jklymaktacaswell
authored andcommitted
MNT: colorbar accept numpy array input (#8739)
Accept a wider range of iterables for `ax`.
1 parent b6eb043 commit 3a58953

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/colorbar.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,10 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
11171117
parent_anchor = kw.pop('panchor', loc_settings['panchor'])
11181118
pad = kw.pop('pad', loc_settings['pad'])
11191119

1120-
# turn parents into a list if it is not already
1121-
if not isinstance(parents, (list, tuple)):
1122-
parents = [parents]
1120+
# turn parents into a list if it is not already. We do this w/ np
1121+
# because `plt.subplots` can return an ndarray and is natural to
1122+
# pass to `colorbar`.
1123+
parents = np.atleast_1d(parents).ravel()
11231124

11241125
fig = parents[0].get_figure()
11251126
if not all(fig is ax.get_figure() for ax in parents):

0 commit comments

Comments
 (0)