Skip to content

Commit 4ace2a4

Browse files
committed
Colorbar now accepts ndarray of axes, not just list
1 parent b07fbb8 commit 4ace2a4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/matplotlib/colorbar.py

+4-3
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 `ax=plt.subplots(1,1)` is an ndarray and is natural to
1122+
# pass to `colorbar`.
1123+
parents = np.atleast_1d(parents).ravel().tolist()
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)