diff --git a/SciDataTool/Functions/Plot/__init__.py b/SciDataTool/Functions/Plot/__init__.py index f4f60aa1..8d442db1 100644 --- a/SciDataTool/Functions/Plot/__init__.py +++ b/SciDataTool/Functions/Plot/__init__.py @@ -53,6 +53,7 @@ "freqs": "frequency", "cr_band": "critical band rate", "z": "axial direction", + "loadcases": "load cases", } fft_dict = { diff --git a/SciDataTool/GUI/DDataPlotter/DDataPlotter.py b/SciDataTool/GUI/DDataPlotter/DDataPlotter.py index bf7ce0d2..db76451f 100644 --- a/SciDataTool/GUI/DDataPlotter/DDataPlotter.py +++ b/SciDataTool/GUI/DDataPlotter/DDataPlotter.py @@ -207,15 +207,18 @@ def format_coord(x, y, z=None, sep=", "): if ticklabel._x == x: X_str = ticklabel._text break - try: - y_float = float(self.ax.get_yticklabels()[-1]._text) + if "mathdefault" in self.ax.get_yticklabels()[-1]._text: Y_str = format(y, ".4g") - except: - Y_str = None - for ticklabel in self.ax.get_yticklabels(): - if ticklabel._y == y: - Y_str = ticklabel._text - break + else: + try: + 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(): + if ticklabel._y == y: + Y_str = ticklabel._text + break if X_str is None or Y_str is None: return "" @@ -300,12 +303,17 @@ def format_coord(x, y, z=None, sep=", "): def set_cursor(event): plot_obj = event.artist Z = None + legend = None if isinstance(plot_obj, Line2D): ind = event.ind xdata = plot_obj.get_xdata() ydata = plot_obj.get_ydata() X = xdata[ind][0] # X position of the click Y = ydata[ind][0] # Y position of the click + if self.fig.legend() not in [None, []]: + legend = ( + self.fig.legend().texts[self.ax.lines.index(plot_obj)]._text + ) elif isinstance(plot_obj, PathCollection): ind = event.ind X = plot_obj.get_offsets().data[ind][0][0] @@ -342,6 +350,8 @@ def set_cursor(event): dx = (x_max - x_min) / 50 if X is not None and Y is not None: label = format_coord(X, Y, Z, sep="\n") + if legend is not None: + label = legend + "\n" + label if label != "": if self.text is None: # Create label in box and black cross