diff --git a/src/View/Results/PlotH.py b/src/View/Results/PlotH.py index 2a626a36b2919ca54e9aa3399b59f8aba6304318..2b33f48c8f6b8dec5a77cb6ba1c898b0eee84c3d 100644 --- a/src/View/Results/PlotH.py +++ b/src/View/Results/PlotH.py @@ -54,6 +54,10 @@ class PlotH(PamhyrPlot): self.label_x = _translate("Results", "Time (s)") self.label_y = _translate("Results", "Discharge (m³/s)") + self.label_discharge = _translate("Results", "Cross-section discharge") + self.label_discharge_max = _translate("Results", "Max discharge") + self.label_timestamp = _translate("Results", "Current timestamp") + self._isometric_axis = False self._auto_relim_update = True @@ -88,6 +92,8 @@ class PlotH(PamhyrPlot): self.set_ticks_time_formater() + self.enable_legend() + self.idle() self._init = True @@ -100,6 +106,7 @@ class PlotH(PamhyrPlot): self._line, = self.canvas.axes.plot( x, y, + label=self.label_discharge, color=self.color_plot, **self.plot_default_kargs ) @@ -112,6 +119,7 @@ class PlotH(PamhyrPlot): self._current, = self.canvas.axes.plot( self._current_timestamp, y[self.ts.index(self._current_timestamp)], + # label=self.label_timestamp, color=self.color_plot_current, **kargs ) @@ -131,6 +139,7 @@ class PlotH(PamhyrPlot): self._line_max, = self.canvas.axes.plot( x, y, + label=self.label_discharge_max, color=self.color_plot_highlight, linestyle='dotted', **self.plot_default_kargs diff --git a/src/View/Tools/PamhyrPlot.py b/src/View/Tools/PamhyrPlot.py index df11dfdbad6472e856c98e41f925a3e46c73673a..309c4b7b1b37581656d4024a195d77315396c415 100644 --- a/src/View/Tools/PamhyrPlot.py +++ b/src/View/Tools/PamhyrPlot.py @@ -200,3 +200,10 @@ class PamhyrPlot(APlot): labelsize=9, labelrotation=45 ) + + def enable_legend(self): + self.canvas.axes.legend( + fancybox=True, + shadow=True, + fontsize=8 + )