@@ -839,8 +839,7 @@ def axhline(self, y=0, xmin=0, xmax=1, **kwargs):
839
839
ymin , ymax = self .get_ybound ()
840
840
841
841
# Strip away the units for comparison with non-unitized bounds.
842
- self ._process_unit_info ({"y" : y }, kwargs )
843
- yy = self .convert_yunits (y )
842
+ yy , = self ._process_unit_info ({"y" : y }, kwargs )
844
843
scaley = (yy < ymin ) or (yy > ymax )
845
844
846
845
trans = self .get_yaxis_transform (which = 'grid' )
@@ -907,8 +906,7 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
907
906
xmin , xmax = self .get_xbound ()
908
907
909
908
# Strip away the units for comparison with non-unitized bounds.
910
- self ._process_unit_info ({"x" : x }, kwargs )
911
- xx = self .convert_xunits (x )
909
+ xx , = self ._process_unit_info ({"x" : x }, kwargs )
912
910
scalex = (xx < xmin ) or (xx > xmax )
913
911
914
912
trans = self .get_xaxis_transform (which = 'grid' )
@@ -1048,11 +1046,9 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
1048
1046
self ._check_no_units ([xmin , xmax ], ['xmin' , 'xmax' ])
1049
1047
trans = self .get_yaxis_transform (which = 'grid' )
1050
1048
1051
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
1052
-
1053
1049
# first we need to strip away the units
1054
- xmin , xmax = self .convert_xunits ([ xmin , xmax ])
1055
- ymin , ymax = self . convert_yunits ( [ymin , ymax ])
1050
+ ( xmin , xmax ), ( ymin , ymax ) = self ._process_unit_info (
1051
+ { "x" : [ xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
1056
1052
1057
1053
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
1058
1054
p = mpatches .Polygon (verts , ** kwargs )
@@ -1108,11 +1104,9 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
1108
1104
self ._check_no_units ([ymin , ymax ], ['ymin' , 'ymax' ])
1109
1105
trans = self .get_xaxis_transform (which = 'grid' )
1110
1106
1111
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
1112
-
1113
1107
# first we need to strip away the units
1114
- xmin , xmax = self .convert_xunits ([ xmin , xmax ])
1115
- ymin , ymax = self . convert_yunits ( [ymin , ymax ])
1108
+ ( xmin , xmax ), ( ymin , ymax ) = self ._process_unit_info (
1109
+ { "x" : [ xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
1116
1110
1117
1111
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
1118
1112
p = mpatches .Polygon (verts , ** kwargs )
@@ -1158,10 +1152,8 @@ def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
1158
1152
"""
1159
1153
1160
1154
# We do the conversion first since not all unitized data is uniform
1161
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : y }, kwargs )
1162
- y = self .convert_yunits (y )
1163
- xmin = self .convert_xunits (xmin )
1164
- xmax = self .convert_xunits (xmax )
1155
+ (xmin , xmax ), y = self ._process_unit_info (
1156
+ {"x" : [xmin , xmax ], "y" : y }, kwargs )
1165
1157
1166
1158
if not np .iterable (y ):
1167
1159
y = [y ]
@@ -1239,10 +1231,8 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
1239
1231
"""
1240
1232
1241
1233
# We do the conversion first since not all unitized data is uniform
1242
- self ._process_unit_info ({"x" : x , "y" : [ymin , ymax ]}, kwargs )
1243
- x = self .convert_xunits (x )
1244
- ymin = self .convert_yunits (ymin )
1245
- ymax = self .convert_yunits (ymax )
1234
+ x , (ymin , ymax ) = self ._process_unit_info (
1235
+ {"x" : x , "y" : [ymin , ymax ]}, kwargs )
1246
1236
1247
1237
if not np .iterable (x ):
1248
1238
x = [x ]
@@ -1380,13 +1370,9 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1380
1370
--------
1381
1371
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
1382
1372
"""
1383
- self ._process_unit_info (
1384
- {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1385
-
1386
1373
# We do the conversion first since not all unitized data is uniform
1387
- positions = self .convert_xunits (positions )
1388
- lineoffsets = self .convert_yunits (lineoffsets )
1389
- linelengths = self .convert_yunits (linelengths )
1374
+ positions , (lineoffsets , linelengths ) = self ._process_unit_info (
1375
+ {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1390
1376
1391
1377
if not np .iterable (positions ):
1392
1378
positions = [positions ]
@@ -2409,11 +2395,13 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2409
2395
x = 0
2410
2396
2411
2397
if orientation == 'vertical' :
2412
- self ._process_unit_info ({"x" : x , "y" : height }, kwargs )
2398
+ self ._process_unit_info (
2399
+ {"x" : x , "y" : height }, kwargs , convert = False )
2413
2400
if log :
2414
2401
self .set_yscale ('log' , nonpositive = 'clip' )
2415
2402
elif orientation == 'horizontal' :
2416
- self ._process_unit_info ({"x" : width , "y" : y }, kwargs )
2403
+ self ._process_unit_info (
2404
+ {"x" : width , "y" : y }, kwargs , convert = False )
2417
2405
if log :
2418
2406
self .set_xscale ('log' , nonpositive = 'clip' )
2419
2407
@@ -2693,7 +2681,8 @@ def broken_barh(self, xranges, yrange, **kwargs):
2693
2681
ydata = cbook .safe_first_element (yrange )
2694
2682
else :
2695
2683
ydata = None
2696
- self ._process_unit_info ({"x" : xdata , "y" : ydata }, kwargs )
2684
+ self ._process_unit_info (
2685
+ {"x" : xdata , "y" : ydata }, kwargs , convert = False )
2697
2686
xranges_conv = []
2698
2687
for xr in xranges :
2699
2688
if len (xr ) != 2 :
@@ -2814,13 +2803,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2814
2803
locs , heads , * args = args
2815
2804
2816
2805
if orientation == 'vertical' :
2817
- self ._process_unit_info ({"x" : locs , "y" : heads })
2818
- locs = self .convert_xunits (locs )
2819
- heads = self .convert_yunits (heads )
2806
+ locs , heads = self ._process_unit_info ({"x" : locs , "y" : heads })
2820
2807
else :
2821
- self ._process_unit_info ({"x" : heads , "y" : locs })
2822
- heads = self .convert_xunits (heads )
2823
- locs = self .convert_yunits (locs )
2808
+ heads , locs = self ._process_unit_info ({"x" : heads , "y" : locs })
2824
2809
2825
2810
# defaults for formats
2826
2811
if linefmt is None :
@@ -3304,7 +3289,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
3304
3289
if int (offset ) != offset :
3305
3290
raise ValueError ("errorevery's starting index must be an integer" )
3306
3291
3307
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
3292
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
3308
3293
3309
3294
# Make sure all the args are iterable; use lists not arrays to preserve
3310
3295
# units.
@@ -4472,9 +4457,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4472
4457
"""
4473
4458
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
4474
4459
4475
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4476
- x = self .convert_xunits (x )
4477
- y = self .convert_yunits (y )
4460
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4478
4461
4479
4462
# np.ma.ravel yields an ndarray, not a masked array,
4480
4463
# unless its argument is a masked array.
@@ -4703,7 +4686,7 @@ def reduce_C_function(C: array) -> float
4703
4686
%(PolyCollection)s
4704
4687
4705
4688
"""
4706
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4689
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
4707
4690
4708
4691
x , y , C = cbook .delete_masked_points (x , y , C )
4709
4692
@@ -5052,9 +5035,7 @@ def quiverkey(self, Q, X, Y, U, label, **kw):
5052
5035
def _quiver_units (self , args , kw ):
5053
5036
if len (args ) > 3 :
5054
5037
x , y = args [0 :2 ]
5055
- self ._process_unit_info ({"x" : x , "y" : y }, kw )
5056
- x = self .convert_xunits (x )
5057
- y = self .convert_yunits (y )
5038
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kw )
5058
5039
return (x , y ) + args [2 :]
5059
5040
return args
5060
5041
@@ -5240,8 +5221,9 @@ def _fill_between_x_or_y(
5240
5221
self ._get_patches_for_fill .get_next_color ()
5241
5222
5242
5223
# Handle united data, such as dates
5243
- self ._process_unit_info ({ind_dir : ind , dep_dir : dep1 }, kwargs )
5244
- self ._process_unit_info ({dep_dir : dep2 })
5224
+ self ._process_unit_info ({ind_dir : ind , dep_dir : dep1 }, kwargs ,
5225
+ convert = False )
5226
+ self ._process_unit_info ({dep_dir : dep2 }, convert = False )
5245
5227
5246
5228
# Convert the arrays so we can work with them
5247
5229
ind = ma .masked_invalid (getattr (self , f"convert_{ ind_dir } units" )(ind ))
@@ -5855,9 +5837,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5855
5837
Ny , Nx = X .shape
5856
5838
5857
5839
# unit conversion allows e.g. datetime objects as axis values
5858
- self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
5859
- X = self .convert_xunits (X )
5860
- Y = self .convert_yunits (Y )
5840
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
5861
5841
5862
5842
# convert to MA, if necessary.
5863
5843
C = ma .asarray (C )
@@ -6132,9 +6112,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6132
6112
X = X .ravel ()
6133
6113
Y = Y .ravel ()
6134
6114
# unit conversion allows e.g. datetime objects as axis values
6135
- self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
6136
- X = self .convert_xunits (X )
6137
- Y = self .convert_yunits (Y )
6115
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
6138
6116
6139
6117
# convert to one dimensional arrays
6140
6118
C = C .ravel ()
@@ -6617,7 +6595,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6617
6595
# Process unit information
6618
6596
# Unit conversion is done individually on each dataset
6619
6597
self ._process_unit_info (
6620
- {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs )
6598
+ {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs ,
6599
+ convert = False )
6621
6600
x = [self .convert_xunits (xi ) for xi in x ]
6622
6601
6623
6602
if bin_range is not None :
0 commit comments