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

Results: CustomPlot: Add legend and change axes label fontsize for each plot.

Showing with 60 additions and 32 deletions
+60 -32
...@@ -72,11 +72,11 @@ class PlotAC(PamhyrPlot): ...@@ -72,11 +72,11 @@ class PlotAC(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Transverse abscissa (m)"), _translate("MainWindow_reach", "Transverse abscissa (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Height (m)"), _translate("MainWindow_reach", "Height (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.figure.tight_layout() self.canvas.figure.tight_layout()
...@@ -176,11 +176,11 @@ class PlotAC(PamhyrPlot): ...@@ -176,11 +176,11 @@ class PlotAC(PamhyrPlot):
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5) self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Abscisse en travers (m)"), _translate("MainWindow_reach", "Abscisse en travers (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Cote (m)"), _translate("MainWindow_reach", "Cote (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.figure.tight_layout() self.canvas.figure.tight_layout()
......
...@@ -64,11 +64,11 @@ class PlotKPZ(PamhyrPlot): ...@@ -64,11 +64,11 @@ class PlotKPZ(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Kp (m)"), _translate("MainWindow_reach", "Kp (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Height (m)"), _translate("MainWindow_reach", "Height (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
kp = self.data.get_kp() kp = self.data.get_kp()
......
...@@ -65,11 +65,11 @@ class PlotXY(PamhyrPlot): ...@@ -65,11 +65,11 @@ class PlotXY(PamhyrPlot):
# Axes # Axes
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("Geometry", "X (m)"), _translate("Geometry", "X (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("Geometry", "Y (m)"), _translate("Geometry", "Y (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.axis("equal") self.canvas.axes.axis("equal")
......
...@@ -86,16 +86,19 @@ class CustomPlot(PamhyrPlot): ...@@ -86,16 +86,19 @@ class CustomPlot(PamhyrPlot):
if "0-meter" in self._y_axes and "1-m3s" in self._y_axes: if "0-meter" in self._y_axes and "1-m3s" in self._y_axes:
m3s_axes = self._axes["1-m3s"] m3s_axes = self._axes["1-m3s"]
lines = {}
if "elevation" in self._y: if "elevation" in self._y:
meter_axes.set_ylim( meter_axes.set_ylim(
bottom=min(0, min(z_min)), bottom=min(0, min(z_min)),
top=max(z_min) + 1 top=max(z_min) + 1
) )
meter_axes.plot( line = meter_axes.plot(
kp, z_min, kp, z_min,
color='grey', lw=1. color='grey', lw=1.,
) )
lines["elevation"] = line
if "water_elevation" in self._y: if "water_elevation" in self._y:
# Water elevation # Water elevation
...@@ -111,10 +114,11 @@ class CustomPlot(PamhyrPlot): ...@@ -111,10 +114,11 @@ class CustomPlot(PamhyrPlot):
top=max(water_z) + 1 top=max(water_z) + 1
) )
meter_axes.plot( line = meter_axes.plot(
kp, water_z, lw=1., kp, water_z, lw=1.,
color='b', color='blue',
) )
lines["water_elevation"] = line
if "elevation" in self._y: if "elevation" in self._y:
meter_axes.fill_between( meter_axes.fill_between(
...@@ -135,10 +139,20 @@ class CustomPlot(PamhyrPlot): ...@@ -135,10 +139,20 @@ class CustomPlot(PamhyrPlot):
top=max(q) + 1 top=max(q) + 1
) )
m3s_axes.plot( line = m3s_axes.plot(
kp, q, lw=1., kp, q, lw=1.,
color='r', color='r',
) )
lines["discharge"] = line
# Legend
lns = reduce(
lambda acc, l: acc + l,
map(lambda l: lines[l], lines),
[]
)
labs = list(map(lambda l: self._trad[l], lines))
self.canvas.axes.legend(lns, labs, loc="lower left")
def _customize_x_axes_time(self, ts, mode="time"): def _customize_x_axes_time(self, ts, mode="time"):
# Custom time display # Custom time display
...@@ -198,6 +212,7 @@ class CustomPlot(PamhyrPlot): ...@@ -198,6 +212,7 @@ class CustomPlot(PamhyrPlot):
) )
x = ts x = ts
lines = {}
if "elevation" in self._y: if "elevation" in self._y:
# Z min is constant in time # Z min is constant in time
z_min = profile.geometry.z_min() z_min = profile.geometry.z_min()
...@@ -208,10 +223,11 @@ class CustomPlot(PamhyrPlot): ...@@ -208,10 +223,11 @@ class CustomPlot(PamhyrPlot):
) )
) )
meter_axes.plot( line = meter_axes.plot(
ts, ts_z_min, ts, ts_z_min,
color='grey', lw=1. color='grey', lw=1.
) )
lines["elevation"] = line
if "water_elevation" in self._y: if "water_elevation" in self._y:
# Water elevation # Water elevation
...@@ -222,10 +238,11 @@ class CustomPlot(PamhyrPlot): ...@@ -222,10 +238,11 @@ class CustomPlot(PamhyrPlot):
top=max(z) + 1 top=max(z) + 1
) )
meter_axes.plot( line = meter_axes.plot(
ts, z, lw=1., ts, z, lw=1.,
color='b', color='b',
) )
lines["water_elevation"] = line
if "elevation" in self._y: if "elevation" in self._y:
z_min = profile.geometry.z_min() z_min = profile.geometry.z_min()
...@@ -249,13 +266,24 @@ class CustomPlot(PamhyrPlot): ...@@ -249,13 +266,24 @@ class CustomPlot(PamhyrPlot):
top=max(q) + 1 top=max(q) + 1
) )
m3s_axes.plot( line = m3s_axes.plot(
ts, q, lw=1., ts, q, lw=1.,
color='r', color='r',
) )
lines["discharge"] = line
self._customize_x_axes_time(ts) self._customize_x_axes_time(ts)
# Legend
lns = reduce(
lambda acc, l: acc + l,
map(lambda l: lines[l], lines),
[]
)
labs = list(map(lambda l: self._trad[l], lines))
self.canvas.axes.legend(lns, labs, loc="lower left")
@timer @timer
def draw(self): def draw(self):
self.canvas.axes.cla() self.canvas.axes.cla()
...@@ -266,12 +294,12 @@ class CustomPlot(PamhyrPlot): ...@@ -266,12 +294,12 @@ class CustomPlot(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
self._trad[self._x], self._trad[self._x],
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
self._trad[self._y_axes[0]], self._trad[self._y_axes[0]],
color='green', fontsize=12 color='green', fontsize=10
) )
for axes in self._y_axes[1:]: for axes in self._y_axes[1:]:
...@@ -281,7 +309,7 @@ class CustomPlot(PamhyrPlot): ...@@ -281,7 +309,7 @@ class CustomPlot(PamhyrPlot):
ax_new = self.canvas.axes.twinx() ax_new = self.canvas.axes.twinx()
ax_new.set_ylabel( ax_new.set_ylabel(
self._trad[axes], self._trad[axes],
color='green', fontsize=12 color='green', fontsize=10
) )
self._axes[axes] = ax_new self._axes[axes] = ax_new
......
...@@ -77,11 +77,11 @@ class PlotH(PamhyrPlot): ...@@ -77,11 +77,11 @@ class PlotH(PamhyrPlot):
# Axes # Axes
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("Results", "Time (s)"), _translate("Results", "Time (s)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("Results", "Discharge (m³/s)"), _translate("Results", "Discharge (m³/s)"),
color='green', fontsize=12 color='green', fontsize=10
) )
ts = list(self.results.get("timestamps")) ts = list(self.results.get("timestamps"))
......
...@@ -122,11 +122,11 @@ class PlotSedProfile(PamhyrPlot): ...@@ -122,11 +122,11 @@ class PlotSedProfile(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "X (m)"), _translate("MainWindow_reach", "X (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Height (m)"), _translate("MainWindow_reach", "Height (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
x = profile.geometry.get_station() x = profile.geometry.get_station()
......
...@@ -203,11 +203,11 @@ class PlotSedReach(PamhyrPlot): ...@@ -203,11 +203,11 @@ class PlotSedReach(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Kp (m)"), _translate("MainWindow_reach", "Kp (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Height (m)"), _translate("MainWindow_reach", "Height (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
kp = reach.geometry.get_kp() kp = reach.geometry.get_kp()
......
...@@ -78,11 +78,11 @@ class PlotXY(PamhyrPlot): ...@@ -78,11 +78,11 @@ class PlotXY(PamhyrPlot):
# Axes # Axes
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("Results", "X (m)"), _translate("Results", "X (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("Results", "Y (m)"), _translate("Results", "Y (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.axis("equal") self.canvas.axes.axis("equal")
......
...@@ -35,7 +35,7 @@ class Plot(PamhyrPlot): ...@@ -35,7 +35,7 @@ class Plot(PamhyrPlot):
self.canvas.axes.axes.get_xaxis().set_visible(False) self.canvas.axes.axes.get_xaxis().set_visible(False)
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
self._trad["height"], self._trad["height"],
color='green', fontsize=12 color='green', fontsize=10
) )
if self.data is None: if self.data is None:
......
...@@ -46,11 +46,11 @@ class Plot(PamhyrPlot): ...@@ -46,11 +46,11 @@ class Plot(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
self._trad["kp"], self._trad["kp"],
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
self._trad["height"], self._trad["height"],
color='green', fontsize=12 color='green', fontsize=10
) )
kp = self.data.get_kp() kp = self.data.get_kp()
......
...@@ -46,11 +46,11 @@ class Plot(PamhyrPlot): ...@@ -46,11 +46,11 @@ class Plot(PamhyrPlot):
self.canvas.axes.set_xlabel( self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "X (m)"), _translate("MainWindow_reach", "X (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
self.canvas.axes.set_ylabel( self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Height (m)"), _translate("MainWindow_reach", "Height (m)"),
color='green', fontsize=12 color='green', fontsize=10
) )
x = self.data.get_station() x = self.data.get_station()
......
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