From fc7a7bb7fd4a0df733a8e4af8db58a3447a8f341 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Wed, 13 Dec 2023 10:05:25 +0100 Subject: [PATCH] HS: Fix update relim in PlotAC and PlotKPC. --- src/View/HydraulicStructures/PlotAC.py | 28 ++++++++++++++----------- src/View/HydraulicStructures/PlotKPC.py | 4 ++++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/View/HydraulicStructures/PlotAC.py b/src/View/HydraulicStructures/PlotAC.py index 9964686a..c3b68cef 100644 --- a/src/View/HydraulicStructures/PlotAC.py +++ b/src/View/HydraulicStructures/PlotAC.py @@ -108,23 +108,27 @@ class PlotAC(PamhyrPlot): def update(self): if self.line_kp is None: self.draw() - else: - if self._current_reach is None or self._current_profile is None: - self.clear() - return + return - profile = self._current_profile - x = profile.get_station() - z = profile.z() + if self._current_reach is None or self._current_profile is None: + self.clear() + return - self.line_kp.set_data(x, z) + profile = self._current_profile + x = profile.get_station() + z = profile.z() - self.canvas.axes.set_xlim( - left=min(x), right=max(x) - ) - self.canvas.figure.canvas.draw_idle() + self.line_kp.set_data(x, z) + + self.canvas.axes.relim() + self.canvas.axes.autoscale_view() + + self.canvas.figure.tight_layout() + self.canvas.figure.canvas.draw_idle() def clear(self): if self.line_kp is not None: self.line_kp.set_data([], []) + + self.canvas.figure.tight_layout() self.canvas.figure.canvas.draw_idle() diff --git a/src/View/HydraulicStructures/PlotKPC.py b/src/View/HydraulicStructures/PlotKPC.py index d3070c88..47ef289c 100644 --- a/src/View/HydraulicStructures/PlotKPC.py +++ b/src/View/HydraulicStructures/PlotKPC.py @@ -139,6 +139,10 @@ class PlotKPC(PamhyrPlot): [self._current_profile.kp, self._current_profile.kp], [self._current_profile.z_min(), self._current_profile.z_max()], ) + + self.canvas.axes.relim() + self.canvas.axes.autoscale_view() + self.canvas.figure.canvas.draw_idle() def clear(self): -- GitLab