@@ -151,18 +151,7 @@ def set_prop_cycle(self, *args, **kwargs):
151
151
self ._prop_keys = prop_cycler .keys
152
152
153
153
def __call__ (self , * args , ** kwargs ):
154
- # Process units.
155
- if self .axes .xaxis is not None and self .axes .yaxis is not None :
156
- xunits = kwargs .pop ('xunits' , self .axes .xaxis .units )
157
- if self .axes .name == 'polar' :
158
- xunits = kwargs .pop ('thetaunits' , xunits )
159
- if xunits != self .axes .xaxis .units :
160
- self .axes .xaxis .set_units (xunits )
161
- yunits = kwargs .pop ('yunits' , self .axes .yaxis .units )
162
- if self .axes .name == 'polar' :
163
- yunits = kwargs .pop ('runits' , yunits )
164
- if yunits != self .axes .yaxis .units :
165
- self .axes .yaxis .set_units (yunits )
154
+ self .axes ._process_unit_info (kwargs = kwargs )
166
155
167
156
for pos_only in "xy" :
168
157
if pos_only in kwargs :
@@ -232,46 +221,6 @@ def get_next_color(self):
232
221
return 'k'
233
222
return next (self .prop_cycler )['color' ]
234
223
235
- def _xy_from_xy (self , x , y ):
236
- if self .axes .xaxis is not None and self .axes .yaxis is not None :
237
- bx = self .axes .xaxis .update_units (x )
238
- by = self .axes .yaxis .update_units (y )
239
-
240
- if self .command != 'plot' :
241
- # the Line2D class can handle unitized data, with
242
- # support for post hoc unit changes etc. Other mpl
243
- # artists, e.g., Polygon which _process_plot_var_args
244
- # also serves on calls to fill, cannot. So this is a
245
- # hack to say: if you are not "plot", which is
246
- # creating Line2D, then convert the data now to
247
- # floats. If you are plot, pass the raw data through
248
- # to Line2D which will handle the conversion. So
249
- # polygons will not support post hoc conversions of
250
- # the unit type since they are not storing the orig
251
- # data. Hopefully we can rationalize this at a later
252
- # date - JDH
253
- if bx :
254
- x = self .axes .convert_xunits (x )
255
- if by :
256
- y = self .axes .convert_yunits (y )
257
-
258
- # like asanyarray, but converts scalar to array, and doesn't change
259
- # existing compatible sequences
260
- x = _check_1d (x )
261
- y = _check_1d (y )
262
- if x .shape [0 ] != y .shape [0 ]:
263
- raise ValueError ("x and y must have same first dimension, but "
264
- "have shapes {} and {}" .format (x .shape , y .shape ))
265
- if x .ndim > 2 or y .ndim > 2 :
266
- raise ValueError ("x and y can be no greater than 2-D, but have "
267
- "shapes {} and {}" .format (x .shape , y .shape ))
268
-
269
- if x .ndim == 1 :
270
- x = x [:, np .newaxis ]
271
- if y .ndim == 1 :
272
- y = y [:, np .newaxis ]
273
- return x , y
274
-
275
224
def _getdefaults (self , ignore , kw ):
276
225
"""
277
226
If some keys in the property cycle (excluding those in the set
@@ -307,6 +256,10 @@ def _makeline(self, x, y, kw, kwargs):
307
256
return seg
308
257
309
258
def _makefill (self , x , y , kw , kwargs ):
259
+ # Polygon doesn't directly support unitized inputs.
260
+ x = self .axes .convert_xunits (x )
261
+ y = self .axes .convert_yunits (y )
262
+
310
263
kw = kw .copy () # Don't modify the original kw.
311
264
kwargs = kwargs .copy ()
312
265
@@ -364,9 +317,8 @@ def _plot_args(self, tup, kwargs):
364
317
else :
365
318
linestyle , marker , color = None , None , None
366
319
367
- # Don't allow any None value; These will be up-converted
368
- # to one element array of None which causes problems
369
- # downstream.
320
+ # Don't allow any None value; these would be up-converted to one
321
+ # element array of None which causes problems downstream.
370
322
if any (v is None for v in tup ):
371
323
raise ValueError ("x, y, and format string must not be None" )
372
324
@@ -382,7 +334,21 @@ def _plot_args(self, tup, kwargs):
382
334
else :
383
335
x , y = index_of (tup [- 1 ])
384
336
385
- x , y = self ._xy_from_xy (x , y )
337
+ if self .axes .xaxis is not None :
338
+ self .axes .xaxis .update_units (x )
339
+ if self .axes .yaxis is not None :
340
+ self .axes .yaxis .update_units (y )
341
+
342
+ if x .shape [0 ] != y .shape [0 ]:
343
+ raise ValueError (f"x and y must have same first dimension, but "
344
+ f"have shapes { x .shape } and { y .shape } " )
345
+ if x .ndim > 2 or y .ndim > 2 :
346
+ raise ValueError (f"x and y can be no greater than 2-D, but have "
347
+ f"shapes { x .shape } and { y .shape } " )
348
+ if x .ndim == 1 :
349
+ x = x [:, np .newaxis ]
350
+ if y .ndim == 1 :
351
+ y = y [:, np .newaxis ]
386
352
387
353
if self .command == 'plot' :
388
354
func = self ._makeline
0 commit comments