Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c78bb92

Browse files
committed
FIX: decorate funcs which take 2d data
1 parent 4d1ffb8 commit c78bb92

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
902902
self.autoscale_view(scaley=False)
903903
return p
904904

905-
@unpack_labeled_data(replace_names=['y', 'xmin', 'xmax'])
905+
@unpack_labeled_data(replace_names=['y', 'xmin', 'xmax'], label_namer="y")
906906
@docstring.dedent
907907
def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
908908
label='', **kwargs):
@@ -2251,7 +2251,7 @@ def barh(self, bottom, width, height=0.8, left=None, **kwargs):
22512251
bottom=bottom, orientation='horizontal', **kwargs)
22522252
return patches
22532253

2254-
# @unpack_labeled_data() # not df["name"] getable...
2254+
@unpack_labeled_data(label_namer=None)
22552255
@docstring.dedent_interpd
22562256
def broken_barh(self, xranges, yrange, **kwargs):
22572257
"""
@@ -3661,7 +3661,8 @@ def dopatch(xs, ys, **kwargs):
36613661
medians=medians, fliers=fliers, means=means)
36623662

36633663
@unpack_labeled_data(replace_names=["x", "y", "s", "c", "linewidths", "edgecolors",
3664-
'facecolor']) # alias for c
3664+
'facecolor', 'facecolors', 'color'], # alias for c
3665+
label_namer="y")
36653666
@docstring.dedent_interpd
36663667
def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
36673668
vmin=None, vmax=None, alpha=None, linewidths=None,
@@ -3869,7 +3870,7 @@ def scatter(self, x, y, s=20, c=None, marker='o', cmap=None, norm=None,
38693870

38703871
return collection
38713872

3872-
@unpack_labeled_data(replace_names=["x", "y"])
3873+
@unpack_labeled_data(replace_names=["x", "y"], label_namer="y")
38733874
@docstring.dedent_interpd
38743875
def hexbin(self, x, y, C=None, gridsize=100, bins=None,
38753876
xscale='linear', yscale='linear', extent=None,
@@ -4386,7 +4387,7 @@ def stackplot(self, x, *args, **kwargs):
43864387
return mstack.stackplot(self, x, *args, **kwargs)
43874388
stackplot.__doc__ = mstack.stackplot.__doc__
43884389

4389-
#@unpack_labeled_data() # doesn't really work, as x and y have different shapes
4390+
@unpack_labeled_data(replace_names=["x", "y", "u", "v", "start_points"], label_namer=None)
43904391
def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
43914392
cmap=None, norm=None, arrowsize=1, arrowstyle='-|>',
43924393
minlength=0.1, transform=None, zorder=1, start_points=None):
@@ -4756,7 +4757,7 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
47564757
return collection
47574758

47584759
#### plotting z(x,y): imshow, pcolor and relatives, contour
4759-
#@unpack_labeled_data() # nothing which could be in an DataFrame
4760+
@unpack_labeled_data(label_namer=None)
47604761
@docstring.dedent_interpd
47614762
def imshow(self, X, cmap=None, norm=None, aspect=None,
47624763
interpolation=None, alpha=None, vmin=None, vmax=None,
@@ -4961,7 +4962,7 @@ def _pcolorargs(funcname, *args, **kw):
49614962
C = C[:Ny - 1, :Nx - 1]
49624963
return X, Y, C
49634964

4964-
#@unpack_labeled_data() # 2d data can't be df["name"]'ed
4965+
@unpack_labeled_data(label_namer=None)
49654966
@docstring.dedent_interpd
49664967
def pcolor(self, *args, **kwargs):
49674968
"""
@@ -5238,7 +5239,7 @@ def pcolor(self, *args, **kwargs):
52385239
self.add_collection(collection, autolim=False)
52395240
return collection
52405241

5241-
#@unpack_labeled_data() # 2d data can't be df["name"]'ed
5242+
@unpack_labeled_data(label_namer=None)
52425243
@docstring.dedent_interpd
52435244
def pcolormesh(self, *args, **kwargs):
52445245
"""
@@ -5387,7 +5388,7 @@ def pcolormesh(self, *args, **kwargs):
53875388
self.add_collection(collection, autolim=False)
53885389
return collection
53895390

5390-
#@unpack_labeled_data() #2d data can't be df["name"]'ed
5391+
@unpack_labeled_data(label_namer=None)
53915392
@docstring.dedent_interpd
53925393
def pcolorfast(self, *args, **kwargs):
53935394
"""

0 commit comments

Comments
 (0)