@@ -871,6 +871,8 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
871
871
self .autoscale_view (scalex = scalex , scaley = False )
872
872
return l
873
873
874
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ],
875
+ convert_y = ['ymin' , 'ymax' ])
874
876
@docstring .dedent_interpd
875
877
def axhspan (self , ymin , ymax , xmin = 0 , xmax = 1 , ** kwargs ):
876
878
"""
@@ -912,21 +914,15 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
912
914
axvspan : Add a vertical span across the axes.
913
915
"""
914
916
trans = self .get_yaxis_transform (which = 'grid' )
915
-
916
- # process the unit information
917
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
918
-
919
- # first we need to strip away the units
920
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
921
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
922
-
923
917
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
924
918
p = mpatches .Polygon (verts , ** kwargs )
925
919
p .set_transform (trans )
926
920
self .add_patch (p )
927
921
self .autoscale_view (scalex = False )
928
922
return p
929
923
924
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ],
925
+ convert_y = ['ymin' , 'ymax' ])
930
926
def axvspan (self , xmin , xmax , ymin = 0 , ymax = 1 , ** kwargs ):
931
927
"""
932
928
Add a vertical span (rectangle) across the axes.
@@ -977,21 +973,14 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
977
973
978
974
"""
979
975
trans = self .get_xaxis_transform (which = 'grid' )
980
-
981
- # process the unit information
982
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
983
-
984
- # first we need to strip away the units
985
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
986
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
987
-
988
976
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
989
977
p = mpatches .Polygon (verts , ** kwargs )
990
978
p .set_transform (trans )
991
979
self .add_patch (p )
992
980
self .autoscale_view (scaley = False )
993
981
return p
994
982
983
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ], convert_y = ['y' ])
995
984
@_preprocess_data (replace_names = ["y" , "xmin" , "xmax" , "colors" ],
996
985
label_namer = "y" )
997
986
def hlines (self , y , xmin , xmax , colors = 'k' , linestyles = 'solid' ,
@@ -1027,14 +1016,6 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
1027
1016
vlines : vertical lines
1028
1017
axhline: horizontal line across the axes
1029
1018
"""
1030
-
1031
- # We do the conversion first since not all unitized data is uniform
1032
- # process the unit information
1033
- self ._process_unit_info ([xmin , xmax ], y , kwargs = kwargs )
1034
- y = self .convert_yunits (y )
1035
- xmin = self .convert_xunits (xmin )
1036
- xmax = self .convert_xunits (xmax )
1037
-
1038
1019
if not np .iterable (y ):
1039
1020
y = [y ]
1040
1021
if not np .iterable (xmin ):
@@ -1068,6 +1049,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
1068
1049
1069
1050
return lines
1070
1051
1052
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['ymin' , 'ymax' ])
1071
1053
@_preprocess_data (replace_names = ["x" , "ymin" , "ymax" , "colors" ],
1072
1054
label_namer = "x" )
1073
1055
def vlines (self , x , ymin , ymax , colors = 'k' , linestyles = 'solid' ,
@@ -1105,14 +1087,6 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
1105
1087
hlines : horizontal lines
1106
1088
axvline: vertical line across the axes
1107
1089
"""
1108
-
1109
- self ._process_unit_info (xdata = x , ydata = [ymin , ymax ], kwargs = kwargs )
1110
-
1111
- # We do the conversion first since not all unitized data is uniform
1112
- x = self .convert_xunits (x )
1113
- ymin = self .convert_yunits (ymin )
1114
- ymax = self .convert_yunits (ymax )
1115
-
1116
1090
if not np .iterable (x ):
1117
1091
x = [x ]
1118
1092
if not np .iterable (ymin ):
@@ -1145,6 +1119,8 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
1145
1119
1146
1120
return lines
1147
1121
1122
+ @munits ._accepts_units (convert_x = ['positions' ],
1123
+ convert_y = ['lineoffsets' , 'linelengths' ])
1148
1124
@_preprocess_data (replace_names = ["positions" , "lineoffsets" ,
1149
1125
"linelengths" , "linewidths" ,
1150
1126
"colors" , "linestyles" ],
@@ -1234,15 +1210,6 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
1234
1210
1235
1211
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
1236
1212
"""
1237
- self ._process_unit_info (xdata = positions ,
1238
- ydata = [lineoffsets , linelengths ],
1239
- kwargs = kwargs )
1240
-
1241
- # We do the conversion first since not all unitized data is uniform
1242
- positions = self .convert_xunits (positions )
1243
- lineoffsets = self .convert_yunits (lineoffsets )
1244
- linelengths = self .convert_yunits (linelengths )
1245
-
1246
1213
if not np .iterable (positions ):
1247
1214
positions = [positions ]
1248
1215
elif any (np .iterable (position ) for position in positions ):
@@ -4919,6 +4886,7 @@ def fill(self, *args, **kwargs):
4919
4886
self .autoscale_view ()
4920
4887
return patches
4921
4888
4889
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['y1' , 'y2' ])
4922
4890
@_preprocess_data (replace_names = ["x" , "y1" , "y2" , "where" ],
4923
4891
label_namer = None )
4924
4892
@docstring .dedent_interpd
@@ -5012,14 +4980,10 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
5012
4980
kwargs ['facecolor' ] = \
5013
4981
self ._get_patches_for_fill .get_next_color ()
5014
4982
5015
- # Handle united data, such as dates
5016
- self ._process_unit_info (xdata = x , ydata = y1 , kwargs = kwargs )
5017
- self ._process_unit_info (ydata = y2 )
5018
-
5019
4983
# Convert the arrays so we can work with them
5020
- x = ma .masked_invalid (self . convert_xunits ( x ) )
5021
- y1 = ma .masked_invalid (self . convert_yunits ( y1 ) )
5022
- y2 = ma .masked_invalid (self . convert_yunits ( y2 ) )
4984
+ x = ma .masked_invalid (x )
4985
+ y1 = ma .masked_invalid (y1 )
4986
+ y2 = ma .masked_invalid (y2 )
5023
4987
5024
4988
for name , array in [('x' , x ), ('y1' , y1 ), ('y2' , y2 )]:
5025
4989
if array .ndim > 1 :
@@ -5102,6 +5066,7 @@ def get_interp_point(ind):
5102
5066
self .autoscale_view ()
5103
5067
return collection
5104
5068
5069
+ @munits ._accepts_units (convert_x = ['x1' , 'x2' ], convert_y = ['y' ])
5105
5070
@_preprocess_data (replace_names = ["y" , "x1" , "x2" , "where" ],
5106
5071
label_namer = None )
5107
5072
@docstring .dedent_interpd
@@ -5195,14 +5160,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
5195
5160
kwargs ['facecolor' ] = \
5196
5161
self ._get_patches_for_fill .get_next_color ()
5197
5162
5198
- # Handle united data, such as dates
5199
- self ._process_unit_info (ydata = y , xdata = x1 , kwargs = kwargs )
5200
- self ._process_unit_info (xdata = x2 )
5201
-
5202
5163
# Convert the arrays so we can work with them
5203
- y = ma .masked_invalid (self . convert_yunits ( y ) )
5204
- x1 = ma .masked_invalid (self . convert_xunits ( x1 ) )
5205
- x2 = ma .masked_invalid (self . convert_xunits ( x2 ) )
5164
+ y = ma .masked_invalid (y )
5165
+ x1 = ma .masked_invalid (x1 )
5166
+ x2 = ma .masked_invalid (x2 )
5206
5167
5207
5168
for name , array in [('y' , y ), ('x1' , x1 ), ('x2' , x2 )]:
5208
5169
if array .ndim > 1 :
0 commit comments