@@ -1245,9 +1245,43 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1245
1245
1246
1246
return colls
1247
1247
1248
+ def _plot_args_replacer (self , args , data ):
1249
+ _replacer = []
1250
+ remaining = args
1251
+ while 1 :
1252
+ if len (remaining ) == 1 :
1253
+ import warnings
1254
+
1255
+ msg = "Missing argument: this can happen if a color spec ('c') is in data"
1256
+ warnings .warn (msg , RuntimeWarning , stacklevel = 3 )
1257
+ _replacer += ["x" ]
1258
+ elif len (remaining ) == 2 :
1259
+ _replacer += ["x" , "y" ]
1260
+ elif len (remaining ) == 3 :
1261
+ if remaining [2 ] in data :
1262
+ import warnings
1263
+
1264
+ msg = "Found a color spec ('c') in data."
1265
+ warnings .warn (msg , RuntimeWarning , stacklevel = 3 )
1266
+ _replacer += ["x" , "y" , "c" ]
1267
+
1268
+ if len (remaining ) <= 3 :
1269
+ return _replacer
1270
+
1271
+ # More than 3 -> split off the beginning and continue
1272
+ if remaining [2 ] not in data :
1273
+ _replacer += ["x" , "y" , "c" ]
1274
+ isplit = 3
1275
+ else :
1276
+ _replacer += ["x" , "y" ]
1277
+ isplit = 2
1278
+ remaining = remaining [isplit :]
1279
+
1248
1280
#### Basic plotting
1249
1281
# The label_naming happens in `matplotlib.axes._base._plot_args`
1250
- @unpack_labeled_data (replace_all_args = True , label_namer = None )
1282
+ @unpack_labeled_data (replace_names = ["x" , "y" ],
1283
+ positional_parameter_names = _plot_args_replacer ,
1284
+ label_namer = None )
1251
1285
@docstring .dedent_interpd
1252
1286
def plot (self , * args , ** kwargs ):
1253
1287
"""
@@ -4378,6 +4412,7 @@ def quiverkey(self, *args, **kw):
4378
4412
return qk
4379
4413
quiverkey .__doc__ = mquiver .QuiverKey .quiverkey_doc
4380
4414
4415
+ # args can by a combination if X, Y, U, V, C and all should be replaced
4381
4416
@unpack_labeled_data (replace_all_args = True , label_namer = None )
4382
4417
def quiver (self , * args , ** kw ):
4383
4418
if not self ._hold :
@@ -4389,6 +4424,7 @@ def quiver(self, *args, **kw):
4389
4424
return q
4390
4425
quiver .__doc__ = mquiver .Quiver .quiver_doc
4391
4426
4427
+ # args can by either Y or y1,y2,... and all should be replaced
4392
4428
@unpack_labeled_data (replace_all_args = True , label_namer = None )
4393
4429
def stackplot (self , x , * args , ** kwargs ):
4394
4430
return mstack .stackplot (self , x , * args , ** kwargs )
@@ -4416,6 +4452,7 @@ def streamplot(self, x, y, u, v, density=1, linewidth=None, color=None,
4416
4452
return stream_container
4417
4453
streamplot .__doc__ = mstream .streamplot .__doc__
4418
4454
4455
+ # args can be some combination of X, Y, U, V, C and all should be replaced
4419
4456
@unpack_labeled_data (replace_all_args = True , label_namer = None )
4420
4457
@docstring .dedent_interpd
4421
4458
def barbs (self , * args , ** kw ):
@@ -7155,7 +7192,7 @@ def matshow(self, Z, **kwargs):
7155
7192
integer = True ))
7156
7193
return im
7157
7194
7158
- @unpack_labeled_data (replace_all_args = True , label_namer = None )
7195
+ @unpack_labeled_data (replace_names = [ "dataset" ] , label_namer = None )
7159
7196
def violinplot (self , dataset , positions = None , vert = True , widths = 0.5 ,
7160
7197
showmeans = False , showextrema = True , showmedians = False ,
7161
7198
points = 100 , bw_method = None ):
@@ -7260,7 +7297,6 @@ def _kde_method(X, coords):
7260
7297
widths = widths , showmeans = showmeans ,
7261
7298
showextrema = showextrema , showmedians = showmedians )
7262
7299
7263
- @unpack_labeled_data (replace_all_args = True , label_namer = None )
7264
7300
def violin (self , vpstats , positions = None , vert = True , widths = 0.5 ,
7265
7301
showmeans = False , showextrema = True , showmedians = False ):
7266
7302
"""Drawing function for violin plots.
0 commit comments