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:
|
if self._current_profile is None:
|
||||||
self.line_kp = None
|
self.line_kp = None
|
||||||
else:
|
else:
|
||||||
|
|
||||||
profile = self._current_profile
|
profile = self._current_profile
|
||||||
x = profile.get_station()
|
x = profile.get_station()
|
||||||
z = profile.z()
|
z = profile.z()
|
||||||
|
|
||||||
self.canvas.axes.set_xlim(
|
|
||||||
left=min(x), right=max(x)
|
|
||||||
)
|
|
||||||
self.line_kp, = self.canvas.axes.plot(
|
self.line_kp, = self.canvas.axes.plot(
|
||||||
x, z,
|
x, z,
|
||||||
linestyle="solid",
|
linestyle="solid",
|
||||||
|
|
@ -92,6 +88,9 @@ class PlotAC(PamhyrPlot):
|
||||||
color='grey',
|
color='grey',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.canvas.axes.relim()
|
||||||
|
self.canvas.axes.autoscale_view()
|
||||||
|
|
||||||
self.canvas.figure.tight_layout()
|
self.canvas.figure.tight_layout()
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
if self.toolbar is not None:
|
if self.toolbar is not None:
|
||||||
|
|
|
||||||
|
|
@ -83,17 +83,12 @@ class PlotKPC(PamhyrPlot):
|
||||||
z_min = reach.reach.get_z_min()
|
z_min = reach.reach.get_z_min()
|
||||||
z_max = reach.reach.get_z_max()
|
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(
|
self.line_kp_zmin, = self.canvas.axes.plot(
|
||||||
kp, z_min,
|
kp, z_min,
|
||||||
color='grey', lw=1.
|
color='grey', lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(kp) != 0:
|
if len(kp) != 0:
|
||||||
|
|
||||||
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
|
||||||
x=kp,
|
x=kp,
|
||||||
ymin=z_min, ymax=z_max,
|
ymin=z_min, ymax=z_max,
|
||||||
|
|
@ -110,6 +105,7 @@ class PlotKPC(PamhyrPlot):
|
||||||
color='red', lw=1.
|
color='red', lw=1.
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.canvas.axes.relim()
|
||||||
self.canvas.figure.tight_layout()
|
self.canvas.figure.tight_layout()
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
if self.toolbar is not None:
|
if self.toolbar is not None:
|
||||||
|
|
@ -132,6 +128,7 @@ class PlotKPC(PamhyrPlot):
|
||||||
kp = reach.reach.get_kp()
|
kp = reach.reach.get_kp()
|
||||||
z_min = reach.reach.get_z_min()
|
z_min = reach.reach.get_z_min()
|
||||||
z_max = reach.reach.get_z_max()
|
z_max = reach.reach.get_z_max()
|
||||||
|
|
||||||
if self.profile is None:
|
if self.profile is None:
|
||||||
self.draw()
|
self.draw()
|
||||||
else:
|
else:
|
||||||
|
|
@ -142,20 +139,23 @@ class PlotKPC(PamhyrPlot):
|
||||||
|
|
||||||
self.canvas.axes.relim()
|
self.canvas.axes.relim()
|
||||||
self.canvas.axes.autoscale_view()
|
self.canvas.axes.autoscale_view()
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
if self.profile is not None:
|
if self.profile is not None:
|
||||||
self.profile.set_data([], [])
|
self.profile.set_data([], [])
|
||||||
|
|
||||||
if self.line_kp_zmin_zmax is not None:
|
if self.line_kp_zmin_zmax is not None:
|
||||||
self.line_kp_zmin_zmax.remove()
|
self.line_kp_zmin_zmax.remove()
|
||||||
self.line_kp_zmin_zmax = None
|
self.line_kp_zmin_zmax = None
|
||||||
|
|
||||||
if self.line_kp_zmin is not None:
|
if self.line_kp_zmin is not None:
|
||||||
self.line_kp_zmin.set_data([], [])
|
self.line_kp_zmin.set_data([], [])
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
||||||
def clear_profile(self):
|
def clear_profile(self):
|
||||||
if self.profile is not None:
|
if self.profile is not None:
|
||||||
self.profile.set_data([], [])
|
self.profile.set_data([], [])
|
||||||
|
|
||||||
self.canvas.figure.canvas.draw_idle()
|
self.canvas.figure.canvas.draw_idle()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue