mirror of https://gitlab.com/pamhyr/pamhyr2
HS: Fix Plot relim at update.
parent
e4670e4a4d
commit
f96cee145c
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue