@@ -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 ):
0 commit comments