diff --git a/src/View/HydraulicStructures/PlotAC.py b/src/View/HydraulicStructures/PlotAC.py index c3b68cefa63fde4e68aee2cbb415461be8e4f005..4d171968945997795e09919d1ee70e8cf338146a 100644 --- a/src/View/HydraulicStructures/PlotAC.py +++ b/src/View/HydraulicStructures/PlotAC.py @@ -77,14 +77,10 @@ class PlotAC(PamhyrPlot): if self._current_profile is None: self.line_kp = None else: - profile = self._current_profile x = profile.get_station() z = profile.z() - self.canvas.axes.set_xlim( - left=min(x), right=max(x) - ) self.line_kp, = self.canvas.axes.plot( x, z, linestyle="solid", @@ -92,6 +88,9 @@ class PlotAC(PamhyrPlot): color='grey', ) + self.canvas.axes.relim() + self.canvas.axes.autoscale_view() + self.canvas.figure.tight_layout() self.canvas.figure.canvas.draw_idle() if self.toolbar is not None: diff --git a/src/View/HydraulicStructures/PlotKPC.py b/src/View/HydraulicStructures/PlotKPC.py index 47ef289c3a0ad483c9b6b17494445154149db97d..f72cf7fc1d41cdbe15d22ac761bbb6d232a07c0c 100644 --- a/src/View/HydraulicStructures/PlotKPC.py +++ b/src/View/HydraulicStructures/PlotKPC.py @@ -83,17 +83,12 @@ class PlotKPC(PamhyrPlot): z_min = reach.reach.get_z_min() z_max = reach.reach.get_z_max() - self.canvas.axes.set_xlim( - left=min(kp), right=max(kp) - ) - self.line_kp_zmin, = self.canvas.axes.plot( kp, z_min, color='grey', lw=1. ) if len(kp) != 0: - self.line_kp_zmin_zmax = self.canvas.axes.vlines( x=kp, ymin=z_min, ymax=z_max, @@ -110,6 +105,7 @@ class PlotKPC(PamhyrPlot): color='red', lw=1. ) + self.canvas.axes.relim() self.canvas.figure.tight_layout() self.canvas.figure.canvas.draw_idle() if self.toolbar is not None: @@ -132,6 +128,7 @@ class PlotKPC(PamhyrPlot): kp = reach.reach.get_kp() z_min = reach.reach.get_z_min() z_max = reach.reach.get_z_max() + if self.profile is None: self.draw() else: @@ -142,20 +139,23 @@ class PlotKPC(PamhyrPlot): self.canvas.axes.relim() self.canvas.axes.autoscale_view() - self.canvas.figure.canvas.draw_idle() def clear(self): if self.profile is not None: self.profile.set_data([], []) + if self.line_kp_zmin_zmax is not None: self.line_kp_zmin_zmax.remove() self.line_kp_zmin_zmax = None + if self.line_kp_zmin is not None: self.line_kp_zmin.set_data([], []) + self.canvas.figure.canvas.draw_idle() def clear_profile(self): if self.profile is not None: self.profile.set_data([], []) + self.canvas.figure.canvas.draw_idle()