@@ -3654,9 +3654,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
36543654 False turns off, None leaves unchanged.
36553655
36563656 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*.
36603659
36613660 Returns
36623661 -------
@@ -3691,76 +3690,18 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False,
36913690 present is on the right.
36923691
36933692 >>> set_xlim(5000, 0)
3694-
36953693 """
36963694 if right is None and np .iterable (left ):
36973695 left , right = left
36983696 if xmin is not None :
36993697 if left is not None :
3700- raise TypeError (' Cannot pass both `xmin` and `left`' )
3698+ raise TypeError (" Cannot pass both 'left' and 'xmin'" )
37013699 left = xmin
37023700 if xmax is not None :
37033701 if right is not None :
3704- raise TypeError (' Cannot pass both `xmax` and `right`' )
3702+ raise TypeError (" Cannot pass both 'right' and 'xmax'" )
37053703 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 )
37643705
37653706 get_xscale = _axis_method_wrapper ("xaxis" , "get_scale" )
37663707
@@ -3985,9 +3926,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
39853926 *False* turns off, *None* leaves unchanged.
39863927
39873928 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*.
39913931
39923932 Returns
39933933 -------
@@ -4027,71 +3967,13 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False,
40273967 bottom , top = bottom
40283968 if ymin is not None :
40293969 if bottom is not None :
4030- raise TypeError (' Cannot pass both `ymin` and `bottom`' )
3970+ raise TypeError (" Cannot pass both 'bottom' and 'ymin'" )
40313971 bottom = ymin
40323972 if ymax is not None :
40333973 if top is not None :
4034- raise TypeError (' Cannot pass both `ymax` and `top`' )
3974+ raise TypeError (" Cannot pass both 'top' and 'ymax'" )
40353975 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 )
40953977
40963978 get_yscale = _axis_method_wrapper ("yaxis" , "get_scale" )
40973979
0 commit comments