Skip to content
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

Avoid interference of ROI patches with legend auto-placement #2370

Merged
merged 4 commits into from
Mar 21, 2023
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
23 changes: 16 additions & 7 deletions glue/core/roi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,6 @@ def __init__(self, axes, data_space=True):
self._patch.set_visible(False)
if not self._data_space:
self._patch.set_transform(self._axes.transAxes)
self._axes.add_patch(self._patch)

def start_selection(self, event):
if event.inaxes != self._axes:
Expand Down Expand Up @@ -1229,7 +1228,10 @@ def _sync_patch(self):
self._patch.set_height(height)
self._patch.set(**self.plot_opts)
self._patch.set_visible(True)
self._axes.add_patch(self._patch)
else:
if self._patch in self._axes.patches:
self._patch._remove_method(self._patch)
self._patch.set_visible(False)

def __str__(self):
Expand Down Expand Up @@ -1264,7 +1266,6 @@ def __init__(self, axes, data_space=True):
trans = self._axes.transAxes
self._patch = Rectangle((0., 0.), 1., 1., transform=trans, zorder=100)
self._patch.set_visible(False)
self._axes.add_patch(self._patch)

def start_selection(self, event):

Expand Down Expand Up @@ -1336,7 +1337,10 @@ def _sync_patch(self):
self._patch.set_height(1)
self._patch.set(**self.plot_opts)
self._patch.set_visible(True)
self._axes.add_patch(self._patch)
else:
if self._patch in self._axes.patches:
self._patch._remove_method(self._patch)
self._patch.set_visible(False)


Expand Down Expand Up @@ -1368,7 +1372,6 @@ def __init__(self, axes, data_space=True):
trans = self._axes.transAxes
self._patch = Rectangle((0., 0.), 1., 1., transform=trans, zorder=100)
self._patch.set_visible(False)
self._axes.add_patch(self._patch)

def start_selection(self, event):

Expand Down Expand Up @@ -1442,7 +1445,10 @@ def _sync_patch(self):
self._patch.set_width(1)
self._patch.set(**self.plot_opts)
self._patch.set_visible(True)
self._axes.add_patch(self._patch)
else:
if self._patch in self._axes.patches:
self._patch._remove_method(self._patch)
self._patch.set_visible(False)


Expand Down Expand Up @@ -1476,7 +1482,6 @@ def __init__(self, axes, data_space=True):
self._patch = Ellipse((0., 0.), transform=IdentityTransform(),
width=0., height=0., zorder=100)
self._patch.set_visible(False)
self._axes.add_patch(self._patch)

def _sync_patch(self):
if self._roi.defined():
Expand All @@ -1487,7 +1492,10 @@ def _sync_patch(self):
self._patch.height = 2. * r
self._patch.set(**self.plot_opts)
self._patch.set_visible(True)
self._axes.add_patch(self._patch)
else:
if self._patch in self._axes.patches:
self._patch._remove_method(self._patch)
self._patch.set_visible(False)

def start_selection(self, event):
Expand Down Expand Up @@ -1616,16 +1624,17 @@ def __init__(self, axes, roi=None, data_space=True):
self._patch.set_visible(False)
if not self._data_space:
self._patch.set_transform(self._axes.transAxes)
self._axes.add_patch(self._patch)

def _sync_patch(self):
if self._roi.defined():
x, y = self._roi.to_polygon()
self._patch.set_xy(list(zip(x + [x[0]],
y + [y[0]])))
self._patch.set_xy(list(zip(x + [x[0]], y + [y[0]])))
self._patch.set_visible(True)
self._patch.set(**self.plot_opts)
self._axes.add_patch(self._patch)
else:
if self._patch in self._axes.patches:
self._patch._remove_method(self._patch)
self._patch.set_visible(False)

def start_selection(self, event, scrubbing=False):
Expand Down