Skip to content

Commit 6a4e1f1

Browse files
committed
Adjust parent axes limits when clearing floating axes.
Without this patch, calling clear() in a FloatingAxes will reset the limits of the (invisible, parent, rectilinear) axes to (0, 1), (0, 1), instead of the values computed by adjust_axes_lim. For example, try adding a call to ax1.clear() in demo_floating_axes immediately after the call to setup_axes1.
1 parent 73394f2 commit 6a4e1f1

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/mpl_toolkits/axisartist/floating_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,6 @@ def __init__(self, *args, grid_helper, **kwargs):
258258
_api.check_isinstance(GridHelperCurveLinear, grid_helper=grid_helper)
259259
super().__init__(*args, grid_helper=grid_helper, **kwargs)
260260
self.set_aspect(1.)
261-
self.adjust_axes_lim()
262261

263262
def _gen_axes_patch(self):
264263
# docstring inherited
@@ -282,6 +281,7 @@ def clear(self):
282281
orig_patch.set_transform(self.transAxes)
283282
self.patch.set_clip_path(orig_patch)
284283
self.gridlines.set_clip_path(orig_patch)
284+
self.adjust_axes_lim()
285285

286286
def adjust_axes_lim(self):
287287
bbox = self.patch.get_path().get_extents(

lib/mpl_toolkits/axisartist/tests/test_floating_axes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def test_curvelinear4():
8282
tick_formatter1=angle_helper.FormatterDMS(),
8383
tick_formatter2=None)
8484
ax1 = fig.add_subplot(axes_class=FloatingAxes, grid_helper=grid_helper)
85+
ax1.clear() # Check that clear() also restores the correct limits on ax1.
8586

8687
ax1.axis["left"].label.set_text("Test 1")
8788
ax1.axis["right"].label.set_text("Test 2")

0 commit comments

Comments
 (0)