@@ -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" ],
@@ -982,15 +959,6 @@ def eventplot(self, positions, orientation='horizontal', lineoffsets=1,
982
959
983
960
.. plot:: gallery/lines_bars_and_markers/eventplot_demo.py
984
961
"""
985
- self ._process_unit_info (xdata = positions ,
986
- ydata = [lineoffsets , linelengths ],
987
- kwargs = kwargs )
988
-
989
- # We do the conversion first since not all unitized data is uniform
990
- positions = self .convert_xunits (positions )
991
- lineoffsets = self .convert_yunits (lineoffsets )
992
- linelengths = self .convert_yunits (linelengths )
993
-
994
962
if not iterable (positions ):
995
963
positions = [positions ]
996
964
elif any (iterable (position ) for position in positions ):
@@ -4628,6 +4596,7 @@ def fill(self, *args, **kwargs):
4628
4596
self .autoscale_view ()
4629
4597
return patches
4630
4598
4599
+ @munits ._accepts_units (convert_x = ['x' ], convert_y = ['y1' , 'y2' ])
4631
4600
@_preprocess_data (replace_names = ["x" , "y1" , "y2" , "where" ],
4632
4601
label_namer = None )
4633
4602
@docstring .dedent_interpd
@@ -4721,14 +4690,10 @@ def fill_between(self, x, y1, y2=0, where=None, interpolate=False,
4721
4690
kwargs ['facecolor' ] = \
4722
4691
self ._get_patches_for_fill .get_next_color ()
4723
4692
4724
- # Handle united data, such as dates
4725
- self ._process_unit_info (xdata = x , ydata = y1 , kwargs = kwargs )
4726
- self ._process_unit_info (ydata = y2 )
4727
-
4728
4693
# Convert the arrays so we can work with them
4729
- x = ma .masked_invalid (self . convert_xunits ( x ) )
4730
- y1 = ma .masked_invalid (self . convert_yunits ( y1 ) )
4731
- y2 = ma .masked_invalid (self . convert_yunits ( y2 ) )
4694
+ x = ma .masked_invalid (x )
4695
+ y1 = ma .masked_invalid (y1 )
4696
+ y2 = ma .masked_invalid (y2 )
4732
4697
4733
4698
for name , array in [('x' , x ), ('y1' , y1 ), ('y2' , y2 )]:
4734
4699
if array .ndim > 1 :
@@ -4811,6 +4776,7 @@ def get_interp_point(ind):
4811
4776
self .autoscale_view ()
4812
4777
return collection
4813
4778
4779
+ @munits ._accepts_units (convert_x = ['x1' , 'x2' ], convert_y = ['y' ])
4814
4780
@_preprocess_data (replace_names = ["y" , "x1" , "x2" , "where" ],
4815
4781
label_namer = None )
4816
4782
@docstring .dedent_interpd
@@ -4904,14 +4870,10 @@ def fill_betweenx(self, y, x1, x2=0, where=None,
4904
4870
kwargs ['facecolor' ] = \
4905
4871
self ._get_patches_for_fill .get_next_color ()
4906
4872
4907
- # Handle united data, such as dates
4908
- self ._process_unit_info (ydata = y , xdata = x1 , kwargs = kwargs )
4909
- self ._process_unit_info (xdata = x2 )
4910
-
4911
4873
# Convert the arrays so we can work with them
4912
- y = ma .masked_invalid (self . convert_yunits ( y ) )
4913
- x1 = ma .masked_invalid (self . convert_xunits ( x1 ) )
4914
- x2 = ma .masked_invalid (self . convert_xunits ( x2 ) )
4874
+ y = ma .masked_invalid (y )
4875
+ x1 = ma .masked_invalid (x1 )
4876
+ x2 = ma .masked_invalid (x2 )
4915
4877
4916
4878
for name , array in [('y' , y ), ('x1' , x1 ), ('x2' , x2 )]:
4917
4879
if array .ndim > 1 :
0 commit comments