@@ -709,8 +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
- self ._process_unit_info ({"y" : y }, kwargs )
713
- yy = self .convert_yunits (y )
712
+ yy , = self ._process_unit_info ({"y" : y }, kwargs )
714
713
scaley = (yy < ymin ) or (yy > ymax )
715
714
716
715
trans = self .get_yaxis_transform (which = 'grid' )
@@ -777,8 +776,7 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
777
776
xmin , xmax = self .get_xbound ()
778
777
779
778
# Strip away the units for comparison with non-unitized bounds.
780
- self ._process_unit_info ({"x" : x }, kwargs )
781
- xx = self .convert_xunits (x )
779
+ xx , = self ._process_unit_info ({"x" : x }, kwargs )
782
780
scalex = (xx < xmin ) or (xx > xmax )
783
781
784
782
trans = self .get_xaxis_transform (which = 'grid' )
@@ -918,11 +916,9 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
918
916
self ._check_no_units ([xmin , xmax ], ['xmin' , 'xmax' ])
919
917
trans = self .get_yaxis_transform (which = 'grid' )
920
918
921
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
922
-
923
919
# first we need to strip away the units
924
- xmin , xmax = self .convert_xunits ([ xmin , xmax ])
925
- ymin , ymax = self . convert_yunits ( [ymin , ymax ])
920
+ ( xmin , xmax ), ( ymin , ymax ) = self ._process_unit_info (
921
+ { "x" : [ xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
926
922
927
923
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
928
924
p = mpatches .Polygon (verts , ** kwargs )
@@ -978,11 +974,9 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
978
974
self ._check_no_units ([ymin , ymax ], ['ymin' , 'ymax' ])
979
975
trans = self .get_xaxis_transform (which = 'grid' )
980
976
981
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
982
-
983
977
# first we need to strip away the units
984
- xmin , xmax = self .convert_xunits ([ xmin , xmax ])
985
- ymin , ymax = self . convert_yunits ( [ymin , ymax ])
978
+ ( xmin , xmax ), ( ymin , ymax ) = self ._process_unit_info (
979
+ { "x" : [ xmin , xmax ], "y" : [ymin , ymax ]}, kwargs )
986
980
987
981
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
988
982
p = mpatches .Polygon (verts , ** kwargs )
@@ -1028,10 +1022,8 @@ def hlines(self, y, xmin, xmax, colors=None, linestyles='solid',
1028
1022
"""
1029
1023
1030
1024
# We do the conversion first since not all unitized data is uniform
1031
- self ._process_unit_info ({"x" : [xmin , xmax ], "y" : y }, kwargs )
1032
- y = self .convert_yunits (y )
1033
- xmin = self .convert_xunits (xmin )
1034
- xmax = self .convert_xunits (xmax )
1025
+ (xmin , xmax ), y = self ._process_unit_info (
1026
+ {"x" : [xmin , xmax ], "y" : y }, kwargs )
1035
1027
1036
1028
if not np .iterable (y ):
1037
1029
y = [y ]
@@ -1107,10 +1099,8 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
1107
1099
"""
1108
1100
1109
1101
# We do the conversion first since not all unitized data is uniform
1110
- self ._process_unit_info ({"x" : x , "y" : [ymin , ymax ]}, kwargs )
1111
- x = self .convert_xunits (x )
1112
- ymin = self .convert_yunits (ymin )
1113
- ymax = self .convert_yunits (ymax )
1102
+ x , (ymin , ymax ) = self ._process_unit_info (
1103
+ {"x" : x , "y" : [ymin , ymax ]}, kwargs )
1114
1104
1115
1105
if not np .iterable (x ):
1116
1106
x = [x ]
@@ -1248,13 +1238,9 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1248
1238
--------
1249
1239
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
1250
1240
"""
1251
- self ._process_unit_info (
1252
- {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1253
-
1254
1241
# We do the conversion first since not all unitized data is uniform
1255
- positions = self .convert_xunits (positions )
1256
- lineoffsets = self .convert_yunits (lineoffsets )
1257
- linelengths = self .convert_yunits (linelengths )
1242
+ positions , (lineoffsets , linelengths ) = self ._process_unit_info (
1243
+ {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1258
1244
1259
1245
if not np .iterable (positions ):
1260
1246
positions = [positions ]
@@ -2276,11 +2262,13 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2276
2262
x = 0
2277
2263
2278
2264
if orientation == 'vertical' :
2279
- self ._process_unit_info ({"x" : x , "y" : height }, kwargs )
2265
+ self ._process_unit_info (
2266
+ {"x" : x , "y" : height }, kwargs , convert = False )
2280
2267
if log :
2281
2268
self .set_yscale ('log' , nonpositive = 'clip' )
2282
2269
elif orientation == 'horizontal' :
2283
- self ._process_unit_info ({"x" : width , "y" : y }, kwargs )
2270
+ self ._process_unit_info (
2271
+ {"x" : width , "y" : y }, kwargs , convert = False )
2284
2272
if log :
2285
2273
self .set_xscale ('log' , nonpositive = 'clip' )
2286
2274
@@ -2560,7 +2548,8 @@ def broken_barh(self, xranges, yrange, **kwargs):
2560
2548
ydata = cbook .safe_first_element (yrange )
2561
2549
else :
2562
2550
ydata = None
2563
- self ._process_unit_info ({"x" : xdata , "y" : ydata }, kwargs )
2551
+ self ._process_unit_info (
2552
+ {"x" : xdata , "y" : ydata }, kwargs , convert = False )
2564
2553
xranges_conv = []
2565
2554
for xr in xranges :
2566
2555
if len (xr ) != 2 :
@@ -2680,13 +2669,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2680
2669
locs , heads , * args = args
2681
2670
2682
2671
if orientation == 'vertical' :
2683
- self ._process_unit_info ({"x" : locs , "y" : heads })
2684
- locs = self .convert_xunits (locs )
2685
- heads = self .convert_yunits (heads )
2672
+ locs , heads = self ._process_unit_info ({"x" : locs , "y" : heads })
2686
2673
else :
2687
- self ._process_unit_info ({"x" : heads , "y" : locs })
2688
- heads = self .convert_xunits (heads )
2689
- locs = self .convert_yunits (locs )
2674
+ heads , locs = self ._process_unit_info ({"x" : heads , "y" : locs })
2690
2675
2691
2676
# defaults for formats
2692
2677
if linefmt is None :
@@ -3170,7 +3155,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
3170
3155
if int (offset ) != offset :
3171
3156
raise ValueError ("errorevery's starting index must be an integer" )
3172
3157
3173
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
3158
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
3174
3159
3175
3160
# Make sure all the args are iterable; use lists not arrays to preserve
3176
3161
# units.
@@ -4337,9 +4322,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4337
4322
"""
4338
4323
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
4339
4324
4340
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4341
- x = self .convert_xunits (x )
4342
- y = self .convert_yunits (y )
4325
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4343
4326
4344
4327
# np.ma.ravel yields an ndarray, not a masked array,
4345
4328
# unless its argument is a masked array.
@@ -4568,7 +4551,7 @@ def reduce_C_function(C: array) -> float
4568
4551
%(PolyCollection)s
4569
4552
4570
4553
"""
4571
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4554
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
4572
4555
4573
4556
x , y , C = cbook .delete_masked_points (x , y , C )
4574
4557
@@ -4917,9 +4900,7 @@ def quiverkey(self, Q, X, Y, U, label, **kw):
4917
4900
def _quiver_units (self , args , kw ):
4918
4901
if len (args ) > 3 :
4919
4902
x , y = args [0 :2 ]
4920
- self ._process_unit_info ({"x" : x , "y" : y }, kw )
4921
- x = self .convert_xunits (x )
4922
- y = self .convert_yunits (y )
4903
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kw )
4923
4904
return (x , y ) + args [2 :]
4924
4905
return args
4925
4906
@@ -5105,8 +5086,9 @@ def _fill_between_x_or_y(
5105
5086
self ._get_patches_for_fill .get_next_color ()
5106
5087
5107
5088
# Handle united data, such as dates
5108
- self ._process_unit_info ({ind_dir : ind , dep_dir : dep1 }, kwargs )
5109
- self ._process_unit_info ({dep_dir : dep2 })
5089
+ self ._process_unit_info ({ind_dir : ind , dep_dir : dep1 }, kwargs ,
5090
+ convert = False )
5091
+ self ._process_unit_info ({dep_dir : dep2 }, convert = False )
5110
5092
5111
5093
# Convert the arrays so we can work with them
5112
5094
ind = ma .masked_invalid (getattr (self , f"convert_{ ind_dir } units" )(ind ))
@@ -5728,9 +5710,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5728
5710
Ny , Nx = X .shape
5729
5711
5730
5712
# unit conversion allows e.g. datetime objects as axis values
5731
- self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
5732
- X = self .convert_xunits (X )
5733
- Y = self .convert_yunits (Y )
5713
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
5734
5714
5735
5715
# convert to MA, if necessary.
5736
5716
C = ma .asarray (C )
@@ -6005,9 +5985,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6005
5985
X = X .ravel ()
6006
5986
Y = Y .ravel ()
6007
5987
# unit conversion allows e.g. datetime objects as axis values
6008
- self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
6009
- X = self .convert_xunits (X )
6010
- Y = self .convert_yunits (Y )
5988
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
6011
5989
6012
5990
# convert to one dimensional arrays
6013
5991
C = C .ravel ()
@@ -6489,7 +6467,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6489
6467
# Process unit information
6490
6468
# Unit conversion is done individually on each dataset
6491
6469
self ._process_unit_info (
6492
- {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs )
6470
+ {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs ,
6471
+ convert = False )
6493
6472
x = [self .convert_xunits (xi ) for xi in x ]
6494
6473
6495
6474
if bin_range is not None :
@@ -6777,9 +6756,8 @@ def stairs(self, values, edges=None, *,
6777
6756
if edges is None :
6778
6757
edges = np .arange (len (values ) + 1 )
6779
6758
6780
- self ._process_unit_info ({"x" : edges , "y" : values }, kwargs )
6781
- edges = self .convert_xunits (edges )
6782
- values = self .convert_yunits (values )
6759
+ edges , values = self ._process_unit_info (
6760
+ {"x" : edges , "y" : values }, kwargs )
6783
6761
6784
6762
patch = mpatches .StepPatch (values ,
6785
6763
edges ,
0 commit comments