Skip to content

Commit 4b6da12

Browse files
Hide crosshair lines from the curve options widget to avoid errors (#39611)
We found a bug with the new crosshair plotting feature where its lines would show up in the plot settings (see comment #39598 (comment)) This pr gives the crosshair lines the label `'_nolegend_'` which means they are ignored by the plot settings. Co-authored-by: thomashampson <thomas.hampson@stfc.ac.uk>
1 parent a20a2f0 commit 4b6da12

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

qt/applications/workbench/workbench/plotting/figuremanager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ def crosshair_toggle(self, on):
611611
for ax in self._axes_that_are_not_colour_bars():
612612
ax.set_autoscalex_on(False)
613613
ax.set_autoscaley_on(False)
614-
hline = ax.axhline(color="r", lw=1.0, ls="-", visible=False)
615-
vline = ax.axvline(color="r", lw=1.0, ls="-", visible=False)
614+
hline = ax.axhline(color="r", lw=1.0, ls="-", visible=False, label="_nolegend_")
615+
vline = ax.axvline(color="r", lw=1.0, ls="-", visible=False, label="_nolegend_")
616616
self._crosshair_lines[ax] = (hline, vline)
617617

618618
self._crosshair_cid = self.canvas.mpl_connect("motion_notify_event", self.crosshair)

qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,15 @@ def curve_in_ax(ax):
8686

8787

8888
def line_in_ax(ax):
89-
"""Return True if there are any lines in the Axes object"""
90-
return len(ax.get_lines()) > 0
89+
"""Return True if there are any lines in the Axes object, ignoring any lines with the _nolegend_ label (e.g. the crosshair)."""
90+
91+
def safe_get_label(line):
92+
if hasattr(line, "get_label"):
93+
return line.get_label()
94+
return ""
95+
96+
filtered_lines = [line for line in ax.get_lines() if not safe_get_label(line) == "_nolegend_"]
97+
return len(filtered_lines) > 0
9198

9299

93100
def errorbars_in_ax(ax):

0 commit comments

Comments
 (0)