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

HS: Fix Plot relim at update.

Showing with 9 additions and 10 deletions
+9 -10
......@@ -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:
......
......@@ -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()
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