Skip to content

Commit d59f9c4

Browse files
committed
Return objects artists plotted column-by-column in silent lists
1 parent 518ecc8 commit d59f9c4

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

proplot/axes/plot.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from numbers import Integral
1010

1111
import matplotlib.axes as maxes
12+
import matplotlib.cbook as cbook
1213
import matplotlib.cm as mcm
1314
import matplotlib.collections as mcollections
1415
import matplotlib.colors as mcolors
@@ -1256,7 +1257,7 @@ def _plot_multicolor(
12561257
ypos = data._safe_mask(ys[1] >= ys[0], *ys)
12571258
kwargs[colorkey] = _not_none(poscolor, rc['poscolor'])
12581259
posobj = self._plot_native(name, x, *ypos, **kwargs)
1259-
return (negobj, posobj)
1260+
return cbook.silent_list(type(negobj), (negobj, posobj))
12601261

12611262
def _plot_errorbars(
12621263
self, x, y, *_, distribution=None,
@@ -2684,7 +2685,7 @@ def _apply_plot(self, *pairs, vert=True, **kwargs):
26842685
edges.append(convert(max_))
26852686

26862687
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
26882689

26892690
@docstring._snippet_manager
26902691
def line(self, *args, **kwargs):
@@ -2749,7 +2750,7 @@ def _apply_step(self, *pairs, vert=True, where='pre', **kwargs):
27492750
objs.append(obj)
27502751

27512752
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
27532754

27542755
@data._preprocess('x', 'y', allow_extra=True)
27552756
@docstring._concatenate_original
@@ -2947,7 +2948,10 @@ def _apply_lines(
29472948
# Draw guide and add sticky edges
29482949
self._add_sticky_edges(objs, 'y' if vert else 'x', *sides)
29492950
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+
)
29512955

29522956
# WARNING: breaking change from native 'ymin' and 'ymax'
29532957
@data._preprocess('x', 'y1', 'y2', ('c', 'color', 'colors'))
@@ -3024,7 +3028,10 @@ def _apply_scatter(self, xs, ys, ss, cc, *, vert=True, **kwargs):
30243028
objs.append((*eb, *es, obj) if eb or es else obj)
30253029

30263030
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+
)
30283035

30293036
@data._preprocess(
30303037
'x', 'y', ('s', 'ms', 'markersize'), ('c', 'color', 'colors'),
@@ -3094,7 +3101,10 @@ def _apply_fill(
30943101
self._update_guide(objs, **guide_kw)
30953102
for axis, sides in zip('xy' if vert else 'yx', (xsides, ysides)):
30963103
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+
)
30983108

30993109
@docstring._snippet_manager
31003110
def area(self, *args, **kwargs):
@@ -3202,7 +3212,10 @@ def _apply_bar(
32023212
objs.append((*eb, obj) if eb else obj)
32033213

32043214
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+
)
32063219

32073220
@data._preprocess('x', 'height', 'width', 'bottom')
32083221
@docstring._concatenate_original
@@ -3455,7 +3468,7 @@ def _apply_hist(self, xs, bins, *, orientation='vertical', **kwargs):
34553468
self._apply_edgefix(obj[2], **edgefix_kw, **kw)
34563469
objs.append(obj)
34573470
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)
34593472

34603473
@data._preprocess('x', 'bins', keywords='weights')
34613474
@docstring._concatenate_original

0 commit comments

Comments
 (0)