@@ -385,6 +385,7 @@ def legend(self, *args, **kwargs):
385
385
def _remove_legend (self , legend ):
386
386
self .legend_ = None
387
387
388
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['y' ])
388
389
def text (self , x , y , s , fontdict = None , withdash = False , ** kwargs ):
389
390
"""
390
391
Add text to the axes.
@@ -619,6 +620,8 @@ def axvline(self, x=0, ymin=0, ymax=1, **kwargs):
619
620
self .autoscale_view (scalex = scalex , scaley = False )
620
621
return l
621
622
623
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ],
624
+ convert_y = ['ymin' , 'ymax' ])
622
625
@docstring .dedent_interpd
623
626
def axhspan (self , ymin , ymax , xmin = 0 , xmax = 1 , ** kwargs ):
624
627
"""
@@ -660,21 +663,15 @@ def axhspan(self, ymin, ymax, xmin=0, xmax=1, **kwargs):
660
663
axvspan : Add a vertical span across the axes.
661
664
"""
662
665
trans = self .get_yaxis_transform (which = 'grid' )
663
-
664
- # process the unit information
665
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
666
-
667
- # first we need to strip away the units
668
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
669
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
670
-
671
666
verts = (xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )
672
667
p = mpatches .Polygon (verts , ** kwargs )
673
668
p .set_transform (trans )
674
669
self .add_patch (p )
675
670
self .autoscale_view (scalex = False )
676
671
return p
677
672
673
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ],
674
+ convert_y = ['ymin' , 'ymax' ])
678
675
def axvspan (self , xmin , xmax , ymin = 0 , ymax = 1 , ** kwargs ):
679
676
"""
680
677
Add a vertical span (rectangle) across the axes.
@@ -725,21 +722,14 @@ def axvspan(self, xmin, xmax, ymin=0, ymax=1, **kwargs):
725
722
726
723
"""
727
724
trans = self .get_xaxis_transform (which = 'grid' )
728
-
729
- # process the unit information
730
- self ._process_unit_info ([xmin , xmax ], [ymin , ymax ], kwargs = kwargs )
731
-
732
- # first we need to strip away the units
733
- xmin , xmax = self .convert_xunits ([xmin , xmax ])
734
- ymin , ymax = self .convert_yunits ([ymin , ymax ])
735
-
736
725
verts = [(xmin , ymin ), (xmin , ymax ), (xmax , ymax ), (xmax , ymin )]
737
726
p = mpatches .Polygon (verts , ** kwargs )
738
727
p .set_transform (trans )
739
728
self .add_patch (p )
740
729
self .autoscale_view (scaley = False )
741
730
return p
742
731
732
+ @munits ._accepts_units (convert_x = ['xmin' , 'xmax' ], convert_y = ['y' ])
743
733
@_preprocess_data (replace_names = ["y" , "xmin" , "xmax" , "colors" ],
744
734
label_namer = "y" )
745
735
def hlines (self , y , xmin , xmax , colors = 'k' , linestyles = 'solid' ,
@@ -775,14 +765,6 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
775
765
vlines : vertical lines
776
766
axhline: horizontal line across the axes
777
767
"""
778
-
779
- # We do the conversion first since not all unitized data is uniform
780
- # process the unit information
781
- self ._process_unit_info ([xmin , xmax ], y , kwargs = kwargs )
782
- y = self .convert_yunits (y )
783
- xmin = self .convert_xunits (xmin )
784
- xmax = self .convert_xunits (xmax )
785
-
786
768
if not iterable (y ):
787
769
y = [y ]
788
770
if not iterable (xmin ):
@@ -816,6 +798,7 @@ def hlines(self, y, xmin, xmax, colors='k', linestyles='solid',
816
798
817
799
return lines
818
800
801
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['ymin' , 'ymax' ])
819
802
@_preprocess_data (replace_names = ["x" , "ymin" , "ymax" , "colors" ],
820
803
label_namer = "x" )
821
804
def vlines (self , x , ymin , ymax , colors = 'k' , linestyles = 'solid' ,
@@ -853,14 +836,6 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
853
836
hlines : horizontal lines
854
837
axvline: vertical line across the axes
855
838
"""
856
-
857
- self ._process_unit_info (xdata = x , ydata = [ymin , ymax ], kwargs = kwargs )
858
-
859
- # We do the conversion first since not all unitized data is uniform
860
- x = self .convert_xunits (x )
861
- ymin = self .convert_yunits (ymin )
862
- ymax = self .convert_yunits (ymax )
863
-
864
839
if not iterable (x ):
865
840
x = [x ]
866
841
if not iterable (ymin ):
@@ -893,6 +868,8 @@ def vlines(self, x, ymin, ymax, colors='k', linestyles='solid',
893
868
894
869
return lines
895
870
871
+ @munits ._accepts_units (convert_x = ['positions' ],
872
+ convert_y = ['lineoffsets' , 'linelengths' ])
896
873
@_preprocess_data (replace_names = ["positions" , "lineoffsets" ,
897
874
"linelengths" , "linewidths" ,
898
875
"colors" , "linestyles" ],
@@ -981,15 +958,6 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
981
958
982
959
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
983
960
"""
984
- self ._process_unit_info (xdata = positions ,
985
- ydata = [lineoffsets , linelengths ],
986
- kwargs = kwargs )
987
-
988
- # We do the conversion first since not all unitized data is uniform
989
- positions = self .convert_xunits (positions )
990
- lineoffsets = self .convert_yunits (lineoffsets )
991
- linelengths = self .convert_yunits (linelengths )
992
-
993
961
if not iterable (positions ):
994
962
positions = [positions ]
995
963
elif any (iterable (position ) for position in positions ):
@@ -4719,6 +4687,7 @@ def fill(self, *args, **kwargs):
4719
4687
self .autoscale_view ()
4720
4688
return patches
4721
4689
4690
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['y1' , 'y2' ])
4722
4691
@_preprocess_data (replace_names = ["x" , "y1" , "y2" , "where" ],
4723
4692
label_namer = None )
4724
4693
@docstring .dedent_interpd
@@ -4812,14 +4781,10 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4812
4781
kwargs ['facecolor' ] = \
4813
4782
self ._get_patches_for_fill .get_next_color ()
4814
4783
4815
- # Handle united data, such as dates
4816
- self ._process_unit_info (xdata = x , ydata = y1 , kwargs = kwargs )
4817
- self ._process_unit_info (ydata = y2 )
4818
-
4819
4784
# Convert the arrays so we can work with them
4820
- x = ma .masked_invalid (self . convert_xunits ( x ) )
4821
- y1 = ma .masked_invalid (self . convert_yunits ( y1 ) )
4822
- y2 = ma .masked_invalid (self . convert_yunits ( y2 ) )
4785
+ x = ma .masked_invalid (x )
4786
+ y1 = ma .masked_invalid (y1 )
4787
+ y2 = ma .masked_invalid (y2 )
4823
4788
4824
4789
for name , array in [('x' , x ), ('y1' , y1 ), ('y2' , y2 )]:
4825
4790
if array .ndim > 1 :
@@ -4902,6 +4867,7 @@ def get_interp_point(ind):
4902
4867
self .autoscale_view ()
4903
4868
return collection
4904
4869
4870
+ @munits ._accepts_units (convert_x = ['x1' , 'x2' ], convert_y = ['y' ])
4905
4871
@_preprocess_data (replace_names = ["y" , "x1" , "x2" , "where" ],
4906
4872
label_namer = None )
4907
4873
@docstring .dedent_interpd
@@ -4995,14 +4961,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
4995
4961
kwargs ['facecolor' ] = \
4996
4962
self ._get_patches_for_fill .get_next_color ()
4997
4963
4998
- # Handle united data, such as dates
4999
- self ._process_unit_info (ydata = y , xdata = x1 , kwargs = kwargs )
5000
- self ._process_unit_info (xdata = x2 )
5001
-
5002
4964
# Convert the arrays so we can work with them
5003
- y = ma .masked_invalid (self . convert_yunits ( y ) )
5004
- x1 = ma .masked_invalid (self . convert_xunits ( x1 ) )
5005
- x2 = ma .masked_invalid (self . convert_xunits ( x2 ) )
4965
+ y = ma .masked_invalid (y )
4966
+ x1 = ma .masked_invalid (x1 )
4967
+ x2 = ma .masked_invalid (x2 )
5006
4968
5007
4969
for name , array in [('y' , y ), ('x1' , x1 ), ('x2' , x2 )]:
5008
4970
if array .ndim > 1 :
0 commit comments