|
9 | 9 | from numbers import Integral |
10 | 10 |
|
11 | 11 | import matplotlib.axes as maxes |
| 12 | +import matplotlib.cbook as cbook |
12 | 13 | import matplotlib.cm as mcm |
13 | 14 | import matplotlib.collections as mcollections |
14 | 15 | import matplotlib.colors as mcolors |
@@ -1256,7 +1257,7 @@ def _plot_multicolor( |
1256 | 1257 | ypos = data._safe_mask(ys[1] >= ys[0], *ys) |
1257 | 1258 | kwargs[colorkey] = _not_none(poscolor, rc['poscolor']) |
1258 | 1259 | posobj = self._plot_native(name, x, *ypos, **kwargs) |
1259 | | - return (negobj, posobj) |
| 1260 | + return cbook.silent_list(type(negobj), (negobj, posobj)) |
1260 | 1261 |
|
1261 | 1262 | def _plot_errorbars( |
1262 | 1263 | self, x, y, *_, distribution=None, |
@@ -2684,7 +2685,7 @@ def _apply_plot(self, *pairs, vert=True, **kwargs): |
2684 | 2685 | edges.append(convert(max_)) |
2685 | 2686 |
|
2686 | 2687 | self._update_guide(objs, **guide_kw) |
2687 | | - return objs # always return list to match matplotlib behavior |
| 2688 | + return cbook.silent_list(mlines.Line2D, objs) # always return list |
2688 | 2689 |
|
2689 | 2690 | @docstring._snippet_manager |
2690 | 2691 | def line(self, *args, **kwargs): |
@@ -2749,7 +2750,7 @@ def _apply_step(self, *pairs, vert=True, where='pre', **kwargs): |
2749 | 2750 | objs.append(obj) |
2750 | 2751 |
|
2751 | 2752 | self._update_guide(objs, **guide_kw) |
2752 | | - return objs # always return list to match matplotlib behavior |
| 2753 | + return cbook.silent_list(mlines.Line2D, objs) # always return list |
2753 | 2754 |
|
2754 | 2755 | @data._preprocess('x', 'y', allow_extra=True) |
2755 | 2756 | @docstring._concatenate_original |
@@ -2947,7 +2948,10 @@ def _apply_lines( |
2947 | 2948 | # Draw guide and add sticky edges |
2948 | 2949 | self._add_sticky_edges(objs, 'y' if vert else 'x', *sides) |
2949 | 2950 | self._update_guide(objs, **guide_kw) |
2950 | | - return objs[0] if len(objs) == 1 else objs |
| 2951 | + return ( |
| 2952 | + objs[0] if len(objs) == 1 |
| 2953 | + else cbook.silent_list(mcollections.LineCollection, objs) |
| 2954 | + ) |
2951 | 2955 |
|
2952 | 2956 | # WARNING: breaking change from native 'ymin' and 'ymax' |
2953 | 2957 | @data._preprocess('x', 'y1', 'y2', ('c', 'color', 'colors')) |
@@ -3024,7 +3028,10 @@ def _apply_scatter(self, xs, ys, ss, cc, *, vert=True, **kwargs): |
3024 | 3028 | objs.append((*eb, *es, obj) if eb or es else obj) |
3025 | 3029 |
|
3026 | 3030 | self._update_guide(objs, **guide_kw) |
3027 | | - return objs[0] if len(objs) == 1 else objs |
| 3031 | + return ( |
| 3032 | + objs[0] if len(objs) == 1 |
| 3033 | + else cbook.silent_list(mcollections.PathCollection, objs) |
| 3034 | + ) |
3028 | 3035 |
|
3029 | 3036 | @data._preprocess( |
3030 | 3037 | 'x', 'y', ('s', 'ms', 'markersize'), ('c', 'color', 'colors'), |
@@ -3094,7 +3101,10 @@ def _apply_fill( |
3094 | 3101 | self._update_guide(objs, **guide_kw) |
3095 | 3102 | for axis, sides in zip('xy' if vert else 'yx', (xsides, ysides)): |
3096 | 3103 | self._add_sticky_edges(objs, axis, *sides) |
3097 | | - return objs[0] if len(objs) == 1 else objs |
| 3104 | + return ( |
| 3105 | + objs[0] if len(objs) == 1 |
| 3106 | + else cbook.silent_list(mcollections.PolyCollection, objs) |
| 3107 | + ) |
3098 | 3108 |
|
3099 | 3109 | @docstring._snippet_manager |
3100 | 3110 | def area(self, *args, **kwargs): |
@@ -3202,7 +3212,10 @@ def _apply_bar( |
3202 | 3212 | objs.append((*eb, obj) if eb else obj) |
3203 | 3213 |
|
3204 | 3214 | self._update_guide(objs, **guide_kw) |
3205 | | - return objs[0] if len(objs) == 1 else objs |
| 3215 | + return ( |
| 3216 | + objs[0] if len(objs) == 1 |
| 3217 | + else cbook.silent_list(mcontainer.BarContainer, objs) |
| 3218 | + ) |
3206 | 3219 |
|
3207 | 3220 | @data._preprocess('x', 'height', 'width', 'bottom') |
3208 | 3221 | @docstring._concatenate_original |
@@ -3455,7 +3468,7 @@ def _apply_hist(self, xs, bins, *, orientation='vertical', **kwargs): |
3455 | 3468 | self._apply_edgefix(obj[2], **edgefix_kw, **kw) |
3456 | 3469 | objs.append(obj) |
3457 | 3470 | self._update_guide(objs, **guide_kw) |
3458 | | - return objs[0] if len(objs) == 1 else objs |
| 3471 | + return objs[0] if len(objs) == 1 else cbook.silent_list(objs) |
3459 | 3472 |
|
3460 | 3473 | @data._preprocess('x', 'bins', keywords='weights') |
3461 | 3474 | @docstring._concatenate_original |
|
0 commit comments