Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89a699b

Browse files
authored
Merge pull request #20191 from anntzer/fas
Small simplifications to FloatingAxesBase.
2 parents a73d0a6 + ccd6342 commit 89a699b

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

lib/mpl_toolkits/axisartist/floating_axes.py

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -318,32 +318,24 @@ def __init__(self, *args, **kwargs):
318318
raise ValueError("FloatingAxes requires grid_helper argument")
319319
if not hasattr(grid_helper, "get_boundary"):
320320
raise ValueError("grid_helper must implement get_boundary method")
321-
322-
self._axes_class_floating.__init__(self, *args, **kwargs)
323-
321+
super().__init__(*args, **kwargs)
324322
self.set_aspect(1.)
325323
self.adjust_axes_lim()
326324

327325
def _gen_axes_patch(self):
328326
# docstring inherited
329-
grid_helper = self.get_grid_helper()
330-
t = grid_helper.get_boundary()
331-
return mpatches.Polygon(t)
327+
return mpatches.Polygon(self.get_grid_helper().get_boundary())
332328

333329
def cla(self):
334-
self._axes_class_floating.cla(self)
335-
# HostAxes.cla(self)
330+
super().cla()
336331
self.patch.set_transform(self.transData)
337-
338-
patch = self._axes_class_floating._gen_axes_patch(self)
339-
patch.set_figure(self.figure)
340-
patch.set_visible(False)
341-
patch.set_transform(self.transAxes)
342-
343-
self.patch.set_clip_path(patch)
344-
self.gridlines.set_clip_path(patch)
345-
346-
self._original_patch = patch
332+
# The original patch is not in the draw tree; it is only used for
333+
# clipping purposes.
334+
orig_patch = super()._gen_axes_patch()
335+
orig_patch.set_figure(self.figure)
336+
orig_patch.set_transform(self.transAxes)
337+
self.patch.set_clip_path(orig_patch)
338+
self.gridlines.set_clip_path(orig_patch)
347339

348340
def adjust_axes_lim(self):
349341
grid_helper = self.get_grid_helper()
@@ -363,8 +355,7 @@ def adjust_axes_lim(self):
363355
@functools.lru_cache(None)
364356
def floatingaxes_class_factory(axes_class):
365357
return type("Floating %s" % axes_class.__name__,
366-
(FloatingAxesBase, axes_class),
367-
{'_axes_class_floating': axes_class})
358+
(FloatingAxesBase, axes_class), {})
368359

369360

370361
FloatingAxes = floatingaxes_class_factory(

0 commit comments

Comments
 (0)