@@ -1023,40 +1023,27 @@ def set_default_intervals(self):
1023
1023
# attribute, and the derived code below will check for that
1024
1024
# and use it if it's available (else just use 0..1)
1025
1025
1026
- def _set_lim (self , v0 , v1 , alt0 = None , alt1 = None , * ,
1027
- emit = True , auto , names = ("" , "" )):
1026
+ def _set_lim (self , v0 , v1 , * , emit = True , auto ):
1028
1027
"""
1029
1028
Set view limits.
1030
1029
1031
1030
This method is a helper for the Axes ``set_xlim``, ``set_ylim``, and
1032
- ``set_zlim`` methods. This docstring uses names corresponding to
1033
- ``set_xlim`` for simplicity.
1031
+ ``set_zlim`` methods.
1034
1032
1035
- *names* is the pair of the names of the first two parameters of the
1036
- Axes method (e.g., "left" and "right"). They are only used to generate
1037
- error messages; and can be empty if the limits are known to be valid.
1038
-
1039
- Other parameters are directly forwarded from the Axes limits setter:
1040
- *v0*, *v1*, *alt0*, and *alt1* map to *left*, *right*, *xmin*, and
1041
- *xmax* respectively; *emit* and *auto* are used as is.
1033
+ Parameters
1034
+ ----------
1035
+ v0, v1 : float
1036
+ The view limits. (Passing *v0* as a (low, high) pair is not
1037
+ supported; normalization must occur in the Axes setters.)
1038
+ emit : bool, default: True
1039
+ Whether to notify observers of limit change.
1040
+ auto : bool or None, default: False
1041
+ Whether to turn on autoscaling of the x-axis. True turns on, False
1042
+ turns off, None leaves unchanged.
1042
1043
"""
1043
- v0name , v1name = names # The value names.
1044
1044
name , = [name for name , axis in self .axes ._get_axis_map ().items ()
1045
1045
if axis is self ] # The axis name.
1046
1046
1047
- if v1 is None and np .iterable (v0 ):
1048
- v0 , v1 = v0
1049
- if alt0 is not None :
1050
- if v0 is not None :
1051
- raise TypeError (
1052
- f"Cannot pass both { v0name !r} and '{ name } lim'" )
1053
- v0 = alt0
1054
- if alt1 is not None :
1055
- if v1 is not None :
1056
- raise TypeError (
1057
- f"Cannot pass both { v1name !r} and '{ name } lim'" )
1058
- v1 = alt1
1059
-
1060
1047
self .axes ._process_unit_info ([(name , (v0 , v1 ))], convert = False )
1061
1048
v0 = self .axes ._validate_converted_limits (v0 , self .convert_units )
1062
1049
v1 = self .axes ._validate_converted_limits (v1 , self .convert_units )
@@ -1075,23 +1062,20 @@ def _set_lim(self, v0, v1, alt0=None, alt1=None, *,
1075
1062
# so only grab the limits if we really need them.
1076
1063
old0 , old1 = self .get_view_interval ()
1077
1064
if v0 <= 0 :
1078
- _api .warn_external (
1079
- f"Attempt to set non-positive { v0name } { name } lim on a "
1080
- f"log-scaled axis will be ignored." )
1065
+ _api .warn_external (f"Attempt to set non-positive { name } lim on "
1066
+ f"a log-scaled axis will be ignored." )
1081
1067
v0 = old0
1082
1068
if v1 <= 0 :
1083
- _api .warn_external (
1084
- f"Attempt to set non-positive { v1name } { name } lim on a "
1085
- f"log-scaled axis will be ignored." )
1069
+ _api .warn_external (f"Attempt to set non-positive { name } lim on "
1070
+ f"a log-scaled axis will be ignored." )
1086
1071
v1 = old1
1087
1072
if v0 == v1 :
1088
1073
_api .warn_external (
1089
- f"Attempting to set identical { v0name } == { v1name } == { v0 } "
1074
+ f"Attempting to set identical low and high { name } lims "
1090
1075
f"makes transformation singular; automatically expanding." )
1091
- reverse = v0 > v1
1076
+ reverse = bool ( v0 > v1 ) # explicit cast needed for python3.8+np.bool_.
1092
1077
v0 , v1 = self .get_major_locator ().nonsingular (v0 , v1 )
1093
1078
v0 , v1 = self .limit_range_for_scale (v0 , v1 )
1094
- # cast to bool to avoid bad interaction between python 3.8 and np.bool_
1095
1079
v0 , v1 = sorted ([v0 , v1 ], reverse = bool (reverse ))
1096
1080
1097
1081
self .set_view_interval (v0 , v1 , ignore = True )
@@ -1107,7 +1091,7 @@ def _set_lim(self, v0, v1, alt0=None, alt1=None, *,
1107
1091
for other in self .axes ._shared_axes [name ].get_siblings (self .axes ):
1108
1092
if other is not self .axes :
1109
1093
other ._get_axis_map ()[name ]._set_lim (
1110
- v0 , v1 , emit = False , auto = auto , names = names )
1094
+ v0 , v1 , emit = False , auto = auto )
1111
1095
if other .figure != self .figure :
1112
1096
other .figure .canvas .draw_idle ()
1113
1097
0 commit comments