@@ -3654,9 +3654,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
3654
3654
False turns off, None leaves unchanged.
3655
3655
3656
3656
xmin, xmax : float, optional
3657
- They are equivalent to left and right respectively,
3658
- and it is an error to pass both *xmin* and *left* or
3659
- *xmax* and *right*.
3657
+ They are equivalent to left and right respectively, and it is an
3658
+ error to pass both *xmin* and *left* or *xmax* and *right*.
3660
3659
3661
3660
Returns
3662
3661
-------
@@ -3691,76 +3690,18 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
3691
3690
present is on the right.
3692
3691
3693
3692
>>> set_xlim(5000, 0)
3694
-
3695
3693
"""
3696
3694
if right is None and np .iterable (left ):
3697
3695
left , right = left
3698
3696
if xmin is not None :
3699
3697
if left is not None :
3700
- raise TypeError (' Cannot pass both `xmin` and `left`' )
3698
+ raise TypeError (" Cannot pass both 'left' and 'xmin'" )
3701
3699
left = xmin
3702
3700
if xmax is not None :
3703
3701
if right is not None :
3704
- raise TypeError (' Cannot pass both `xmax` and `right`' )
3702
+ raise TypeError (" Cannot pass both 'right' and 'xmax'" )
3705
3703
right = xmax
3706
-
3707
- self ._process_unit_info ([("x" , (left , right ))], convert = False )
3708
- left = self ._validate_converted_limits (left , self .convert_xunits )
3709
- right = self ._validate_converted_limits (right , self .convert_xunits )
3710
-
3711
- if left is None or right is None :
3712
- # Axes init calls set_xlim(0, 1) before get_xlim() can be called,
3713
- # so only grab the limits if we really need them.
3714
- old_left , old_right = self .get_xlim ()
3715
- if left is None :
3716
- left = old_left
3717
- if right is None :
3718
- right = old_right
3719
-
3720
- if self .get_xscale () == 'log' and (left <= 0 or right <= 0 ):
3721
- # Axes init calls set_xlim(0, 1) before get_xlim() can be called,
3722
- # so only grab the limits if we really need them.
3723
- old_left , old_right = self .get_xlim ()
3724
- if left <= 0 :
3725
- _api .warn_external (
3726
- 'Attempted to set non-positive left xlim on a '
3727
- 'log-scaled axis.\n '
3728
- 'Invalid limit will be ignored.' )
3729
- left = old_left
3730
- if right <= 0 :
3731
- _api .warn_external (
3732
- 'Attempted to set non-positive right xlim on a '
3733
- 'log-scaled axis.\n '
3734
- 'Invalid limit will be ignored.' )
3735
- right = old_right
3736
- if left == right :
3737
- _api .warn_external (
3738
- f"Attempting to set identical left == right == { left } results "
3739
- f"in singular transformations; automatically expanding." )
3740
- reverse = left > right
3741
- left , right = self .xaxis .get_major_locator ().nonsingular (left , right )
3742
- left , right = self .xaxis .limit_range_for_scale (left , right )
3743
- # cast to bool to avoid bad interaction between python 3.8 and np.bool_
3744
- left , right = sorted ([left , right ], reverse = bool (reverse ))
3745
-
3746
- self ._viewLim .intervalx = (left , right )
3747
- # Mark viewlims as no longer stale without triggering an autoscale.
3748
- for ax in self ._shared_axes ["x" ].get_siblings (self ):
3749
- ax ._stale_viewlims ["x" ] = False
3750
- if auto is not None :
3751
- self ._autoscaleXon = bool (auto )
3752
-
3753
- if emit :
3754
- self .callbacks .process ('xlim_changed' , self )
3755
- # Call all of the other x-axes that are shared with this one
3756
- for other in self ._shared_axes ["x" ].get_siblings (self ):
3757
- if other is not self :
3758
- other .set_xlim (self .viewLim .intervalx ,
3759
- emit = False , auto = auto )
3760
- if other .figure != self .figure :
3761
- other .figure .canvas .draw_idle ()
3762
- self .stale = True
3763
- return left , right
3704
+ return self .xaxis ._set_lim (left , right , emit = emit , auto = auto )
3764
3705
3765
3706
get_xscale = _axis_method_wrapper ("xaxis" , "get_scale" )
3766
3707
@@ -3985,9 +3926,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
3985
3926
*False* turns off, *None* leaves unchanged.
3986
3927
3987
3928
ymin, ymax : float, optional
3988
- They are equivalent to bottom and top respectively,
3989
- and it is an error to pass both *ymin* and *bottom* or
3990
- *ymax* and *top*.
3929
+ They are equivalent to bottom and top respectively, and it is an
3930
+ error to pass both *ymin* and *bottom* or *ymax* and *top*.
3991
3931
3992
3932
Returns
3993
3933
-------
@@ -4027,71 +3967,13 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
4027
3967
bottom , top = bottom
4028
3968
if ymin is not None :
4029
3969
if bottom is not None :
4030
- raise TypeError (' Cannot pass both `ymin` and `bottom`' )
3970
+ raise TypeError (" Cannot pass both 'bottom' and 'ymin'" )
4031
3971
bottom = ymin
4032
3972
if ymax is not None :
4033
3973
if top is not None :
4034
- raise TypeError (' Cannot pass both `ymax` and `top`' )
3974
+ raise TypeError (" Cannot pass both 'top' and 'ymax'" )
4035
3975
top = ymax
4036
-
4037
- self ._process_unit_info ([("y" , (bottom , top ))], convert = False )
4038
- bottom = self ._validate_converted_limits (bottom , self .convert_yunits )
4039
- top = self ._validate_converted_limits (top , self .convert_yunits )
4040
-
4041
- if bottom is None or top is None :
4042
- # Axes init calls set_ylim(0, 1) before get_ylim() can be called,
4043
- # so only grab the limits if we really need them.
4044
- old_bottom , old_top = self .get_ylim ()
4045
- if bottom is None :
4046
- bottom = old_bottom
4047
- if top is None :
4048
- top = old_top
4049
-
4050
- if self .get_yscale () == 'log' and (bottom <= 0 or top <= 0 ):
4051
- # Axes init calls set_xlim(0, 1) before get_xlim() can be called,
4052
- # so only grab the limits if we really need them.
4053
- old_bottom , old_top = self .get_ylim ()
4054
- if bottom <= 0 :
4055
- _api .warn_external (
4056
- 'Attempted to set non-positive bottom ylim on a '
4057
- 'log-scaled axis.\n '
4058
- 'Invalid limit will be ignored.' )
4059
- bottom = old_bottom
4060
- if top <= 0 :
4061
- _api .warn_external (
4062
- 'Attempted to set non-positive top ylim on a '
4063
- 'log-scaled axis.\n '
4064
- 'Invalid limit will be ignored.' )
4065
- top = old_top
4066
- if bottom == top :
4067
- _api .warn_external (
4068
- f"Attempting to set identical bottom == top == { bottom } "
4069
- f"results in singular transformations; automatically "
4070
- f"expanding." )
4071
- reverse = bottom > top
4072
- bottom , top = self .yaxis .get_major_locator ().nonsingular (bottom , top )
4073
- bottom , top = self .yaxis .limit_range_for_scale (bottom , top )
4074
- # cast to bool to avoid bad interaction between python 3.8 and np.bool_
4075
- bottom , top = sorted ([bottom , top ], reverse = bool (reverse ))
4076
-
4077
- self ._viewLim .intervaly = (bottom , top )
4078
- # Mark viewlims as no longer stale without triggering an autoscale.
4079
- for ax in self ._shared_axes ["y" ].get_siblings (self ):
4080
- ax ._stale_viewlims ["y" ] = False
4081
- if auto is not None :
4082
- self ._autoscaleYon = bool (auto )
4083
-
4084
- if emit :
4085
- self .callbacks .process ('ylim_changed' , self )
4086
- # Call all of the other y-axes that are shared with this one
4087
- for other in self ._shared_axes ["y" ].get_siblings (self ):
4088
- if other is not self :
4089
- other .set_ylim (self .viewLim .intervaly ,
4090
- emit = False , auto = auto )
4091
- if other .figure != self .figure :
4092
- other .figure .canvas .draw_idle ()
4093
- self .stale = True
4094
- return bottom , top
3976
+ return self .yaxis ._set_lim (bottom , top , emit = emit , auto = auto )
4095
3977
4096
3978
get_yscale = _axis_method_wrapper ("yaxis" , "get_scale" )
4097
3979
0 commit comments