Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def _request_autoscale_view(self, axis="all", tight=None):
Mark a single axis, or all of them, as stale wrt. autoscaling.

No computation is performed until the next autoscaling; thus, separate
calls to control individual `Axis`s incur negligible performance cost.
calls to control individual `Axis`'s incur negligible performance cost.

Parameters
----------
Expand Down Expand Up @@ -1314,8 +1314,9 @@ def __clear(self):
xaxis_visible = self.xaxis.get_visible()
yaxis_visible = self.yaxis.get_visible()

for axis in self._axis_map.values():
axis.clear() # Also resets the scale to linear.
for name, axis in self._axis_map.items():
if self._shared_axes[name].get_siblings(self) == [self]:
axis.clear() # Also resets the scale to linear.
for spine in self.spines.values():
spine._clear() # Use _clear to not clear Axis again

Expand Down Expand Up @@ -1420,6 +1421,9 @@ def __clear(self):
share = getattr(self, f"_share{name}")
if share is not None:
getattr(self, f"share{name}")(share)
elif self in self._shared_axes[name]:
# Do not mess with limits of shared axes.
continue
else:
# Although the scale was set to linear as part of clear,
# polar requires that _set_scale is called again
Expand Down Expand Up @@ -2185,9 +2189,9 @@ def axis(self, arg=None, /, *, emit=True, **kwargs):
xlim = self.get_xlim()
ylim = self.get_ylim()
edge_size = max(np.diff(xlim), np.diff(ylim))[0]
self.set_xlim(xlim[0], xlim[0] + edge_size,
self.set_xlim([xlim[0], xlim[0] + edge_size],
emit=emit, auto=False)
self.set_ylim(ylim[0], ylim[0] + edge_size,
self.set_ylim([ylim[0], ylim[0] + edge_size],
emit=emit, auto=False)
else:
raise ValueError(f"Unrecognized string {arg!r} to axis; "
Expand Down
Loading