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

Skip to content

Small simplifications to FloatingAxesBase. #20191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2021
Merged
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
31 changes: 11 additions & 20 deletions lib/mpl_toolkits/axisartist/floating_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,32 +318,24 @@ def __init__(self, *args, **kwargs):
raise ValueError("FloatingAxes requires grid_helper argument")
if not hasattr(grid_helper, "get_boundary"):
raise ValueError("grid_helper must implement get_boundary method")

self._axes_class_floating.__init__(self, *args, **kwargs)

super().__init__(*args, **kwargs)
self.set_aspect(1.)
self.adjust_axes_lim()

def _gen_axes_patch(self):
# docstring inherited
grid_helper = self.get_grid_helper()
t = grid_helper.get_boundary()
return mpatches.Polygon(t)
return mpatches.Polygon(self.get_grid_helper().get_boundary())

def cla(self):
self._axes_class_floating.cla(self)
# HostAxes.cla(self)
super().cla()
self.patch.set_transform(self.transData)

patch = self._axes_class_floating._gen_axes_patch(self)
patch.set_figure(self.figure)
patch.set_visible(False)
patch.set_transform(self.transAxes)

self.patch.set_clip_path(patch)
self.gridlines.set_clip_path(patch)

self._original_patch = patch
# The original patch is not in the draw tree; it is only used for
# clipping purposes.
orig_patch = super()._gen_axes_patch()
orig_patch.set_figure(self.figure)
orig_patch.set_transform(self.transAxes)
self.patch.set_clip_path(orig_patch)
self.gridlines.set_clip_path(orig_patch)

def adjust_axes_lim(self):
grid_helper = self.get_grid_helper()
Expand All @@ -363,8 +355,7 @@ def adjust_axes_lim(self):
@functools.lru_cache(None)
def floatingaxes_class_factory(axes_class):
return type("Floating %s" % axes_class.__name__,
(FloatingAxesBase, axes_class),
{'_axes_class_floating': axes_class})
(FloatingAxesBase, axes_class), {})


FloatingAxes = floatingaxes_class_factory(
Expand Down