@@ -709,7 +709,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
709
709
ymin , ymax = self .get_ybound ()
710
710
711
711
# Strip away the units for comparison with non-unitized bounds.
712
- yy , = self ._process_unit_info ({ "y" : y } , kwargs )
712
+ yy , = self ._process_unit_info ([( "y" , y )] , kwargs )
713
713
scaley = (yy < ymin ) or (yy > ymax )
714
714
715
715
trans = self .get_yaxis_transform (which = 'grid' )
@@ -776,7 +776,7 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
776
776
xmin , xmax = self .get_xbound ()
777
777
778
778
# Strip away the units for comparison with non-unitized bounds.
779
- xx , = self ._process_unit_info ({ "x" : x } , kwargs )
779
+ xx , = self ._process_unit_info ([( "x" , x )] , kwargs )
780
780
scalex = (xx < xmin ) or (xx > xmax )
781
781
782
782
trans = self .get_xaxis_transform (which = 'grid' )
@@ -918,7 +918,7 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
918
918
919
919
# first we need to strip away the units
920
920
(xmin , xmax ), (ymin , ymax ) = self ._process_unit_info (
921
- { "x" : [xmin , xmax ], "y" : [ymin , ymax ]} , kwargs )
921
+ [( "x" , [xmin , xmax ]), ( "y" , [ymin , ymax ])] , kwargs )
922
922
923
923
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
924
924
p = mpatches .Polygon (verts , ** kwargs )
@@ -976,7 +976,7 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
976
976
977
977
# first we need to strip away the units
978
978
(xmin , xmax ), (ymin , ymax ) = self ._process_unit_info (
979
- { "x" : [xmin , xmax ], "y" : [ymin , ymax ]} , kwargs )
979
+ [( "x" , [xmin , xmax ]), ( "y" , [ymin , ymax ])] , kwargs )
980
980
981
981
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
982
982
p = mpatches .Polygon (verts , ** kwargs )
@@ -1022,11 +1022,8 @@ def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
1022
1022
"""
1023
1023
1024
1024
# We do the conversion first since not all unitized data is uniform
1025
- self ._process_unit_info (
1026
- {"x" : [xmin , xmax ], "y" : y }, kwargs , convert = False )
1027
- y = self .convert_yunits (y )
1028
- xmin = self .convert_xunits (xmin )
1029
- xmax = self .convert_xunits (xmax )
1025
+ xmin , xmax , y = self ._process_unit_info (
1026
+ [("x" , xmin ), ("x" , xmax ), ("y" , y )], kwargs )
1030
1027
1031
1028
if not np .iterable (y ):
1032
1029
y = [y ]
@@ -1102,11 +1099,8 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
1102
1099
"""
1103
1100
1104
1101
# We do the conversion first since not all unitized data is uniform
1105
- self ._process_unit_info (
1106
- {"x" : x , "y" : [ymin , ymax ]}, kwargs , convert = False )
1107
- x = self .convert_xunits (x )
1108
- ymin = self .convert_yunits (ymin )
1109
- ymax = self .convert_yunits (ymax )
1102
+ x , ymin , ymax = self ._process_unit_info (
1103
+ [("x" , x ), ("y" , ymin ), ("y" , ymax )], kwargs )
1110
1104
1111
1105
if not np .iterable (x ):
1112
1106
x = [x ]
@@ -1245,8 +1239,8 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1245
1239
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
1246
1240
"""
1247
1241
# We do the conversion first since not all unitized data is uniform
1248
- positions , ( lineoffsets , linelengths ) = self ._process_unit_info (
1249
- { "x" : positions , "y" : [ lineoffsets , linelengths ]} , kwargs )
1242
+ positions , lineoffsets , linelengths = self ._process_unit_info (
1243
+ [( "x" , positions ), ( "y" , lineoffsets ), ( "y" , linelengths )] , kwargs )
1250
1244
1251
1245
if not np .iterable (positions ):
1252
1246
positions = [positions ]
@@ -2269,12 +2263,12 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2269
2263
2270
2264
if orientation == 'vertical' :
2271
2265
self ._process_unit_info (
2272
- { "x" : x , "y" : height } , kwargs , convert = False )
2266
+ [( "x" , x ), ( "y" , height )] , kwargs , convert = False )
2273
2267
if log :
2274
2268
self .set_yscale ('log' , nonpositive = 'clip' )
2275
2269
elif orientation == 'horizontal' :
2276
2270
self ._process_unit_info (
2277
- { "x" : width , "y" : y } , kwargs , convert = False )
2271
+ [( "x" , width ), ( "y" , y )] , kwargs , convert = False )
2278
2272
if log :
2279
2273
self .set_xscale ('log' , nonpositive = 'clip' )
2280
2274
@@ -2555,7 +2549,7 @@ def broken_barh(self, xranges, yrange, **kwargs):
2555
2549
else :
2556
2550
ydata = None
2557
2551
self ._process_unit_info (
2558
- { "x" : xdata , "y" : ydata } , kwargs , convert = False )
2552
+ [( "x" , xdata ), ( "y" , ydata )] , kwargs , convert = False )
2559
2553
xranges_conv = []
2560
2554
for xr in xranges :
2561
2555
if len (xr ) != 2 :
@@ -2675,9 +2669,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2675
2669
locs , heads , * args = args
2676
2670
2677
2671
if orientation == 'vertical' :
2678
- locs , heads = self ._process_unit_info ({ "x" : locs , "y" : heads } )
2672
+ locs , heads = self ._process_unit_info ([( "x" , locs ), ( "y" , heads )] )
2679
2673
else :
2680
- heads , locs = self ._process_unit_info ({ "x" : heads , "y" : locs } )
2674
+ heads , locs = self ._process_unit_info ([( "x" , heads ), ( "y" , locs )] )
2681
2675
2682
2676
# defaults for formats
2683
2677
if linefmt is None :
@@ -3161,7 +3155,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
3161
3155
if int (offset ) != offset :
3162
3156
raise ValueError ("errorevery's starting index must be an integer" )
3163
3157
3164
- self ._process_unit_info ({ "x" : x , "y" : y } , kwargs , convert = False )
3158
+ self ._process_unit_info ([( "x" , x ), ( "y" , y )] , kwargs , convert = False )
3165
3159
3166
3160
# Make sure all the args are iterable; use lists not arrays to preserve
3167
3161
# units.
@@ -4328,7 +4322,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4328
4322
"""
4329
4323
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
4330
4324
4331
- x , y = self ._process_unit_info ({ "x" : x , "y" : y } , kwargs )
4325
+ x , y = self ._process_unit_info ([( "x" , x ), ( "y" , y )] , kwargs )
4332
4326
4333
4327
# np.ma.ravel yields an ndarray, not a masked array,
4334
4328
# unless its argument is a masked array.
@@ -4557,7 +4551,7 @@ def reduce_C_function(C: array) -> float
4557
4551
%(PolyCollection)s
4558
4552
4559
4553
"""
4560
- self ._process_unit_info ({ "x" : x , "y" : y } , kwargs , convert = False )
4554
+ self ._process_unit_info ([( "x" , x ), ( "y" , y )] , kwargs , convert = False )
4561
4555
4562
4556
x , y , C = cbook .delete_masked_points (x , y , C )
4563
4557
@@ -4906,7 +4900,7 @@ def quiverkey(self, Q, X, Y, U, label, **kw):
4906
4900
def _quiver_units (self , args , kw ):
4907
4901
if len (args ) > 3 :
4908
4902
x , y = args [0 :2 ]
4909
- x , y = self ._process_unit_info ({ "x" : x , "y" : y } , kw )
4903
+ x , y = self ._process_unit_info ([( "x" , x ), ( "y" , y )] , kw )
4910
4904
return (x , y ) + args [2 :]
4911
4905
return args
4912
4906
@@ -5092,9 +5086,9 @@ def _fill_between_x_or_y(
5092
5086
self ._get_patches_for_fill .get_next_color ()
5093
5087
5094
5088
# Handle united data, such as dates
5095
- self ._process_unit_info ({ ind_dir : ind , dep_dir : dep1 }, kwargs ,
5096
- convert = False )
5097
- self . _process_unit_info ({ dep_dir : dep2 }, convert = False )
5089
+ self ._process_unit_info (
5090
+ [( ind_dir , ind ), ( dep_dir , dep1 ), ( dep_dir , dep2 )], kwargs ,
5091
+ convert = False )
5098
5092
5099
5093
# Convert the arrays so we can work with them
5100
5094
ind = ma .masked_invalid (getattr (self , f"convert_{ ind_dir } units" )(ind ))
@@ -5716,7 +5710,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5716
5710
Ny , Nx = X .shape
5717
5711
5718
5712
# unit conversion allows e.g. datetime objects as axis values
5719
- X , Y = self ._process_unit_info ({ "x" : X , "y" : Y } , kwargs )
5713
+ X , Y = self ._process_unit_info ([( "x" , X ), ( "y" , Y )] , kwargs )
5720
5714
5721
5715
# convert to MA, if necessary.
5722
5716
C = ma .asarray (C )
@@ -5991,7 +5985,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
5991
5985
X = X .ravel ()
5992
5986
Y = Y .ravel ()
5993
5987
# unit conversion allows e.g. datetime objects as axis values
5994
- X , Y = self ._process_unit_info ({ "x" : X , "y" : Y } , kwargs )
5988
+ X , Y = self ._process_unit_info ([( "x" , X ), ( "y" , Y )] , kwargs )
5995
5989
5996
5990
# convert to one dimensional arrays
5997
5991
C = C .ravel ()
@@ -6475,11 +6469,11 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6475
6469
# one at a time.
6476
6470
if orientation == "vertical" :
6477
6471
convert_units = self .convert_yunits
6478
- x = [* self ._process_unit_info ({ "x" : x [0 ]} , kwargs ),
6472
+ x = [* self ._process_unit_info ([( "x" , x [0 ])] , kwargs ),
6479
6473
* map (convert_units , x [1 :])]
6480
6474
else : # horizontal
6481
6475
convert_units = self .convert_yunits
6482
- x = [* self ._process_unit_info ({ "y" : x [0 ]} , kwargs ),
6476
+ x = [* self ._process_unit_info ([( "y" , x [0 ])] , kwargs ),
6483
6477
* map (convert_units , x [1 :])]
6484
6478
6485
6479
if bin_range is not None :
@@ -6768,7 +6762,7 @@ def stairs(self, values, edges=None, *,
6768
6762
edges = np .arange (len (values ) + 1 )
6769
6763
6770
6764
edges , values = self ._process_unit_info (
6771
- { "x" : edges , "y" : values } , kwargs )
6765
+ [( "x" , edges ), ( "y" , values )] , kwargs )
6772
6766
6773
6767
patch = mpatches .StepPatch (values ,
6774
6768
edges ,
0 commit comments