@@ -213,8 +213,9 @@ class _process_plot_var_args:
213
213
an arbitrary number of *x*, *y*, *fmt* are allowed
214
214
"""
215
215
216
- def __init__ (self , command = 'plot' ):
217
- self .command = command
216
+ def __init__ (self , output = 'Line2D' ):
217
+ _api .check_in_list (['Line2D' , 'Polygon' , 'coordinates' ], output = output )
218
+ self .output = output
218
219
self .set_prop_cycle (None )
219
220
220
221
def set_prop_cycle (self , cycler ):
@@ -223,12 +224,12 @@ def set_prop_cycle(self, cycler):
223
224
self ._idx = 0
224
225
self ._cycler_items = [* cycler ]
225
226
226
- def __call__ (self , axes , * args , data = None , ** kwargs ):
227
+ def __call__ (self , axes , * args , data = None , return_kwargs = False , ** kwargs ):
227
228
axes ._process_unit_info (kwargs = kwargs )
228
229
229
230
for pos_only in "xy" :
230
231
if pos_only in kwargs :
231
- raise _api .kwarg_error (self . command , pos_only )
232
+ raise _api .kwarg_error (inspect . stack ()[ 1 ]. function , pos_only )
232
233
233
234
if not args :
234
235
return
@@ -294,7 +295,9 @@ def __call__(self, axes, *args, data=None, **kwargs):
294
295
this += args [0 ],
295
296
args = args [1 :]
296
297
yield from self ._plot_args (
297
- axes , this , kwargs , ambiguous_fmt_datakey = ambiguous_fmt_datakey )
298
+ axes , this , kwargs , ambiguous_fmt_datakey = ambiguous_fmt_datakey ,
299
+ return_kwargs = return_kwargs
300
+ )
298
301
299
302
def get_next_color (self ):
300
303
"""Return the next color in the cycle."""
@@ -329,13 +332,18 @@ def _setdefaults(self, defaults, kw):
329
332
if kw .get (k , None ) is None :
330
333
kw [k ] = defaults [k ]
331
334
332
- def _makeline (self , axes , x , y , kw , kwargs ):
335
+ def _make_line (self , axes , x , y , kw , kwargs ):
333
336
kw = {** kw , ** kwargs } # Don't modify the original kw.
334
337
self ._setdefaults (self ._getdefaults (kw ), kw )
335
338
seg = mlines .Line2D (x , y , ** kw )
336
339
return seg , kw
337
340
338
- def _makefill (self , axes , x , y , kw , kwargs ):
341
+ def _make_coordinates (self , axes , x , y , kw , kwargs ):
342
+ kw = {** kw , ** kwargs } # Don't modify the original kw.
343
+ self ._setdefaults (self ._getdefaults (kw ), kw )
344
+ return (x , y ), kw
345
+
346
+ def _make_polygon (self , axes , x , y , kw , kwargs ):
339
347
# Polygon doesn't directly support unitized inputs.
340
348
x = axes .convert_xunits (x )
341
349
y = axes .convert_yunits (y )
@@ -493,11 +501,15 @@ def _plot_args(self, axes, tup, kwargs, *,
493
501
if y .ndim == 1 :
494
502
y = y [:, np .newaxis ]
495
503
496
- if self .command == 'plot ' :
497
- make_artist = self ._makeline
498
- else :
504
+ if self .output == 'Line2D ' :
505
+ make_artist = self ._make_line
506
+ elif self . output == 'Polygon' :
499
507
kw ['closed' ] = kwargs .get ('closed' , True )
500
- make_artist = self ._makefill
508
+ make_artist = self ._make_polygon
509
+ elif self .output == 'coordinates' :
510
+ make_artist = self ._make_coordinates
511
+ else :
512
+ _api .check_in_list (['Line2D' , 'Polygon' , 'coordinates' ], output = self .output )
501
513
502
514
ncx , ncy = x .shape [1 ], y .shape [1 ]
503
515
if ncx > 1 and ncy > 1 and ncx != ncy :
@@ -1299,7 +1311,7 @@ def __clear(self):
1299
1311
self ._use_sticky_edges = True
1300
1312
1301
1313
self ._get_lines = _process_plot_var_args ()
1302
- self ._get_patches_for_fill = _process_plot_var_args ('fill ' )
1314
+ self ._get_patches_for_fill = _process_plot_var_args ('Polygon ' )
1303
1315
1304
1316
self ._gridOn = mpl .rcParams ['axes.grid' ]
1305
1317
# Swap children to minimize time we spend in an invalid state
0 commit comments