@@ -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,7 +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 )
1025
+ self ._process_unit_info (
1026
+ {"x" : [xmin , xmax ], "y" : y }, kwargs , convert = False )
1032
1027
y = self .convert_yunits (y )
1033
1028
xmin = self .convert_xunits (xmin )
1034
1029
xmax = self .convert_xunits (xmax )
@@ -1107,7 +1102,8 @@ def vlines(self, x, ymin, ymax, colors=None, linestyles='solid',
1107
1102
"""
1108
1103
1109
1104
# We do the conversion first since not all unitized data is uniform
1110
- self ._process_unit_info ({"x" : x , "y" : [ymin , ymax ]}, kwargs )
1105
+ self ._process_unit_info (
1106
+ {"x" : x , "y" : [ymin , ymax ]}, kwargs , convert = False )
1111
1107
x = self .convert_xunits (x )
1112
1108
ymin = self .convert_yunits (ymin )
1113
1109
ymax = self .convert_yunits (ymax )
@@ -1248,13 +1244,9 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1248
1244
--------
1249
1245
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
1250
1246
"""
1251
- self ._process_unit_info (
1252
- {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1253
-
1254
1247
# 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 )
1248
+ positions , (lineoffsets , linelengths ) = self ._process_unit_info (
1249
+ {"x" : positions , "y" : [lineoffsets , linelengths ]}, kwargs )
1258
1250
1259
1251
if not np .iterable (positions ):
1260
1252
positions = [positions ]
@@ -2276,11 +2268,13 @@ def bar(self, x, height, width=0.8, bottom=None, *, align="center",
2276
2268
x = 0
2277
2269
2278
2270
if orientation == 'vertical' :
2279
- self ._process_unit_info ({"x" : x , "y" : height }, kwargs )
2271
+ self ._process_unit_info (
2272
+ {"x" : x , "y" : height }, kwargs , convert = False )
2280
2273
if log :
2281
2274
self .set_yscale ('log' , nonpositive = 'clip' )
2282
2275
elif orientation == 'horizontal' :
2283
- self ._process_unit_info ({"x" : width , "y" : y }, kwargs )
2276
+ self ._process_unit_info (
2277
+ {"x" : width , "y" : y }, kwargs , convert = False )
2284
2278
if log :
2285
2279
self .set_xscale ('log' , nonpositive = 'clip' )
2286
2280
@@ -2560,7 +2554,8 @@ def broken_barh(self, xranges, yrange, **kwargs):
2560
2554
ydata = cbook .safe_first_element (yrange )
2561
2555
else :
2562
2556
ydata = None
2563
- self ._process_unit_info ({"x" : xdata , "y" : ydata }, kwargs )
2557
+ self ._process_unit_info (
2558
+ {"x" : xdata , "y" : ydata }, kwargs , convert = False )
2564
2559
xranges_conv = []
2565
2560
for xr in xranges :
2566
2561
if len (xr ) != 2 :
@@ -2680,13 +2675,9 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
2680
2675
locs , heads , * args = args
2681
2676
2682
2677
if orientation == 'vertical' :
2683
- self ._process_unit_info ({"x" : locs , "y" : heads })
2684
- locs = self .convert_xunits (locs )
2685
- heads = self .convert_yunits (heads )
2678
+ locs , heads = self ._process_unit_info ({"x" : locs , "y" : heads })
2686
2679
else :
2687
- self ._process_unit_info ({"x" : heads , "y" : locs })
2688
- heads = self .convert_xunits (heads )
2689
- locs = self .convert_yunits (locs )
2680
+ heads , locs = self ._process_unit_info ({"x" : heads , "y" : locs })
2690
2681
2691
2682
# defaults for formats
2692
2683
if linefmt is None :
@@ -3170,7 +3161,7 @@ def errorbar(self, x, y, yerr=None, xerr=None,
3170
3161
if int (offset ) != offset :
3171
3162
raise ValueError ("errorevery's starting index must be an integer" )
3172
3163
3173
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
3164
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
3174
3165
3175
3166
# Make sure all the args are iterable; use lists not arrays to preserve
3176
3167
# units.
@@ -4337,9 +4328,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4337
4328
"""
4338
4329
# Process **kwargs to handle aliases, conflicts with explicit kwargs:
4339
4330
4340
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4341
- x = self .convert_xunits (x )
4342
- y = self .convert_yunits (y )
4331
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4343
4332
4344
4333
# np.ma.ravel yields an ndarray, not a masked array,
4345
4334
# unless its argument is a masked array.
@@ -4568,7 +4557,7 @@ def reduce_C_function(C: array) -> float
4568
4557
%(PolyCollection)s
4569
4558
4570
4559
"""
4571
- self ._process_unit_info ({"x" : x , "y" : y }, kwargs )
4560
+ self ._process_unit_info ({"x" : x , "y" : y }, kwargs , convert = False )
4572
4561
4573
4562
x , y , C = cbook .delete_masked_points (x , y , C )
4574
4563
@@ -4917,9 +4906,7 @@ def quiverkey(self, Q, X, Y, U, label, **kw):
4917
4906
def _quiver_units (self , args , kw ):
4918
4907
if len (args ) > 3 :
4919
4908
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 )
4909
+ x , y = self ._process_unit_info ({"x" : x , "y" : y }, kw )
4923
4910
return (x , y ) + args [2 :]
4924
4911
return args
4925
4912
@@ -5105,8 +5092,9 @@ def _fill_between_x_or_y(
5105
5092
self ._get_patches_for_fill .get_next_color ()
5106
5093
5107
5094
# 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 })
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 )
5110
5098
5111
5099
# Convert the arrays so we can work with them
5112
5100
ind = ma .masked_invalid (getattr (self , f"convert_{ ind_dir } units" )(ind ))
@@ -5728,9 +5716,7 @@ def pcolor(self, *args, shading=None, alpha=None, norm=None, cmap=None,
5728
5716
Ny , Nx = X .shape
5729
5717
5730
5718
# 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 )
5719
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
5734
5720
5735
5721
# convert to MA, if necessary.
5736
5722
C = ma .asarray (C )
@@ -6005,9 +5991,7 @@ def pcolormesh(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
6005
5991
X = X .ravel ()
6006
5992
Y = Y .ravel ()
6007
5993
# 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 )
5994
+ X , Y = self ._process_unit_info ({"x" : X , "y" : Y }, kwargs )
6011
5995
6012
5996
# convert to one dimensional arrays
6013
5997
C = C .ravel ()
@@ -6489,7 +6473,8 @@ def hist(self, x, bins=None, range=None, density=False, weights=None,
6489
6473
# Process unit information
6490
6474
# Unit conversion is done individually on each dataset
6491
6475
self ._process_unit_info (
6492
- {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs )
6476
+ {"x" if orientation == "vertical" else "y" : x [0 ]}, kwargs ,
6477
+ convert = False )
6493
6478
x = [self .convert_xunits (xi ) for xi in x ]
6494
6479
6495
6480
if bin_range is not None :
@@ -6777,9 +6762,8 @@ def stairs(self, values, edges=None, *,
6777
6762
if edges is None :
6778
6763
edges = np .arange (len (values ) + 1 )
6779
6764
6780
- self ._process_unit_info ({"x" : edges , "y" : values }, kwargs )
6781
- edges = self .convert_xunits (edges )
6782
- values = self .convert_yunits (values )
6765
+ edges , values = self ._process_unit_info (
6766
+ {"x" : edges , "y" : values }, kwargs )
6783
6767
6784
6768
patch = mpatches .StepPatch (values ,
6785
6769
edges ,
0 commit comments