@@ -840,13 +840,14 @@ def _get_autoscale_on(self):
840840 def _set_autoscale_on (self , b ):
841841 """
842842 Set whether this Axis is autoscaled when drawing or by
843- `.Axes.autoscale_view`.
843+ `.Axes.autoscale_view`. If b is None, then the value is not changed.
844844
845845 Parameters
846846 ----------
847847 b : bool
848848 """
849- self ._autoscale_on = b
849+ if b is not None :
850+ self ._autoscale_on = b
850851
851852 def get_children (self ):
852853 return [self .label , self .offsetText ,
@@ -1229,8 +1230,7 @@ def _set_lim(self, v0, v1, *, emit=True, auto):
12291230 # Mark viewlims as no longer stale without triggering an autoscale.
12301231 for ax in self ._get_shared_axes ():
12311232 ax ._stale_viewlims [name ] = False
1232- if auto is not None :
1233- self ._set_autoscale_on (bool (auto ))
1233+ self ._set_autoscale_on (auto )
12341234
12351235 if emit :
12361236 self .axes .callbacks .process (f"{ name } lim_changed" , self .axes )
@@ -1277,6 +1277,17 @@ def _update_ticks(self):
12771277 if view_low > view_high :
12781278 view_low , view_high = view_high , view_low
12791279
1280+ if (hasattr (self , "axes" ) and self .axes .name == '3d'
1281+ and mpl .rcParams ['axes3d.automargin' ]):
1282+ # In mpl3.8, the margin was 1/48. Due to the change in automargin
1283+ # behavior in mpl3.9, we need to adjust this to compensate for a
1284+ # zoom factor of 2/48, giving us a 23/24 modifier. So the new
1285+ # margin is 0.019965277777777776 = 1/48*23/24.
1286+ margin = 0.019965277777777776
1287+ delta = view_high - view_low
1288+ view_high = view_high - delta * margin
1289+ view_low = view_low + delta * margin
1290+
12801291 interval_t = self .get_transform ().transform ([view_low , view_high ])
12811292
12821293 ticks_to_draw = []
0 commit comments