Commit f9a099a2 authored by Pierre-Antoine Rouby's avatar Pierre-Antoine Rouby
Browse files

Results: Hydrograph: Add legend.

Showing with 16 additions and 0 deletions
+16 -0
...@@ -54,6 +54,10 @@ class PlotH(PamhyrPlot): ...@@ -54,6 +54,10 @@ class PlotH(PamhyrPlot):
self.label_x = _translate("Results", "Time (s)") self.label_x = _translate("Results", "Time (s)")
self.label_y = _translate("Results", "Discharge (m³/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._isometric_axis = False
self._auto_relim_update = True self._auto_relim_update = True
...@@ -88,6 +92,8 @@ class PlotH(PamhyrPlot): ...@@ -88,6 +92,8 @@ class PlotH(PamhyrPlot):
self.set_ticks_time_formater() self.set_ticks_time_formater()
self.enable_legend()
self.idle() self.idle()
self._init = True self._init = True
...@@ -100,6 +106,7 @@ class PlotH(PamhyrPlot): ...@@ -100,6 +106,7 @@ class PlotH(PamhyrPlot):
self._line, = self.canvas.axes.plot( self._line, = self.canvas.axes.plot(
x, y, x, y,
label=self.label_discharge,
color=self.color_plot, color=self.color_plot,
**self.plot_default_kargs **self.plot_default_kargs
) )
...@@ -112,6 +119,7 @@ class PlotH(PamhyrPlot): ...@@ -112,6 +119,7 @@ class PlotH(PamhyrPlot):
self._current, = self.canvas.axes.plot( self._current, = self.canvas.axes.plot(
self._current_timestamp, self._current_timestamp,
y[self.ts.index(self._current_timestamp)], y[self.ts.index(self._current_timestamp)],
# label=self.label_timestamp,
color=self.color_plot_current, color=self.color_plot_current,
**kargs **kargs
) )
...@@ -131,6 +139,7 @@ class PlotH(PamhyrPlot): ...@@ -131,6 +139,7 @@ class PlotH(PamhyrPlot):
self._line_max, = self.canvas.axes.plot( self._line_max, = self.canvas.axes.plot(
x, y, x, y,
label=self.label_discharge_max,
color=self.color_plot_highlight, color=self.color_plot_highlight,
linestyle='dotted', linestyle='dotted',
**self.plot_default_kargs **self.plot_default_kargs
......
...@@ -200,3 +200,10 @@ class PamhyrPlot(APlot): ...@@ -200,3 +200,10 @@ class PamhyrPlot(APlot):
labelsize=9, labelsize=9,
labelrotation=45 labelrotation=45
) )
def enable_legend(self):
self.canvas.axes.legend(
fancybox=True,
shadow=True,
fontsize=8
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment