Skip to content

Commit

Permalink
[BC] Adding conditions to prevent bug from testing DDataPlotter
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminGabet committed Jun 8, 2022
1 parent a5fe9d7 commit 699a38b
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions SciDataTool/GUI/DDataPlotter/DDataPlotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from matplotlib.patches import Rectangle
from matplotlib.collections import PathCollection, QuadMesh
from matplotlib.text import Annotation
from numpy import array
from numpy import array, allclose
from SciDataTool.Functions.is_axes_in_order import is_axes_in_order
from SciDataTool.Functions.Plot import TEXT_BOX

Expand Down Expand Up @@ -260,8 +260,11 @@ def format_coord(x, y, z=None, sep=", ", ind=None):
if is_annot:
# Use ticklabels
try:
x_float = float(self.ax.get_xticklabels()[-1]._text)
X_str = format(x, ".4g")
if self.ax.get_xticklabels()[-1]._text == "":
X_str = format(x, ".4g")
else:
x_float = float(self.ax.get_xticklabels()[-1]._text)
X_str = format(x, ".4g")
except:
for ticklabel in self.ax.get_xticklabels():
if ticklabel._x == x:
Expand All @@ -272,8 +275,11 @@ def format_coord(x, y, z=None, sep=", ", ind=None):
Y_str = format(y, ".4g")
else:
try:
y_float = float(self.ax.get_yticklabels()[-1]._text)
Y_str = format(y, ".4g")
if self.ax.get_yticklabels()[-1]._text == "":
Y_str = format(y, ".4g")
else:
y_float = float(self.ax.get_yticklabels()[-1]._text)
Y_str = format(y, ".4g")
except:
Y_str = None
for ticklabel in self.ax.get_yticklabels():
Expand Down Expand Up @@ -394,6 +400,13 @@ def set_cursor(event):
X = xdata[ind][0] # X position of the click
Y = ydata[ind][0] # Y position of the click
if self.ax.get_legend_handles_labels()[1] != []:
try:
self.ax.lines.index(plot_obj) # Test validation mode
except ValueError:
for line in self.ax.lines:
if allclose(ydata, line.get_ydata()):
plot_obj = line
break
legend = self.ax.get_legend_handles_labels()[1][
self.ax.lines.index(plot_obj)
].lstrip(" ")
Expand Down

0 comments on commit 699a38b

Please sign in to comment.