Skip to content

Commit 3a0f1dc

Browse files
authored
Merge pull request #109 from EOMYS-Public/GUI
Modifying DDataPlotter to allow testing on it
2 parents 78b5b28 + b7a12ec commit 3a0f1dc

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

SciDataTool/GUI/DDataPlotter/DDataPlotter.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from matplotlib.patches import Rectangle
1414
from matplotlib.collections import PathCollection, QuadMesh
1515
from matplotlib.text import Annotation
16-
from numpy import array
16+
from numpy import array, allclose
1717
from SciDataTool.Functions.is_axes_in_order import is_axes_in_order
1818
from SciDataTool.Functions.Plot import TEXT_BOX
1919

@@ -260,8 +260,11 @@ def format_coord(x, y, z=None, sep=", ", ind=None):
260260
if is_annot:
261261
# Use ticklabels
262262
try:
263-
x_float = float(self.ax.get_xticklabels()[-1]._text)
264-
X_str = format(x, ".4g")
263+
if self.ax.get_xticklabels()[-1]._text == "":
264+
X_str = format(x, ".4g")
265+
else:
266+
x_float = float(self.ax.get_xticklabels()[-1]._text)
267+
X_str = format(x, ".4g")
265268
except:
266269
for ticklabel in self.ax.get_xticklabels():
267270
if ticklabel._x == x:
@@ -272,8 +275,11 @@ def format_coord(x, y, z=None, sep=", ", ind=None):
272275
Y_str = format(y, ".4g")
273276
else:
274277
try:
275-
y_float = float(self.ax.get_yticklabels()[-1]._text)
276-
Y_str = format(y, ".4g")
278+
if self.ax.get_yticklabels()[-1]._text == "":
279+
Y_str = format(y, ".4g")
280+
else:
281+
y_float = float(self.ax.get_yticklabels()[-1]._text)
282+
Y_str = format(y, ".4g")
277283
except:
278284
Y_str = None
279285
for ticklabel in self.ax.get_yticklabels():
@@ -394,6 +400,13 @@ def set_cursor(event):
394400
X = xdata[ind][0] # X position of the click
395401
Y = ydata[ind][0] # Y position of the click
396402
if self.ax.get_legend_handles_labels()[1] != []:
403+
try:
404+
self.ax.lines.index(plot_obj) # Test validation mode
405+
except ValueError:
406+
for line in self.ax.lines:
407+
if allclose(ydata, line.get_ydata()):
408+
plot_obj = line
409+
break
397410
legend = self.ax.get_legend_handles_labels()[1][
398411
self.ax.lines.index(plot_obj)
399412
].lstrip(" ")

0 commit comments

Comments
 (0)