From 57024e768e4ef856887e141f765050a0dd0c0327 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Fri, 8 Apr 2022 11:19:59 +0200 Subject: [PATCH] Add information on animation --- swash/processing/animate.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/swash/processing/animate.py b/swash/processing/animate.py index 473df88..b6cd8ff 100644 --- a/swash/processing/animate.py +++ b/swash/processing/animate.py @@ -30,7 +30,7 @@ def data(var): x = data("x") -# t = data("t") +t = data("t") watl = data("watl") botl = data("botl") @@ -40,6 +40,9 @@ wl = np.maximum(watl, -botl) fig, ax = plt.subplots() ax.plot(x, -botl, c="k") +ax.set(xlim=(x.min(), x.max()), ylim=(-30, 10), xlabel="x (m)", ylabel="z (m)") +tit = ax.text(0.5, 0, f't={t[0]}', horizontalalignment='center', verticalalignment='bottom', transform=ax.transAxes) +ax.grid() # ax.fill_between( # x, -botl, -data["botl"] + bathy.hstru, color="k", alpha=0.2 # ) @@ -48,7 +51,9 @@ ax.plot(x, -botl, c="k") def animate(i): line.set_ydata(wl[i]) - return (line,) + tit.set_text(f"t={t[i]*1e-3:.2f}s") + + return (line, tit) ani = animation.FuncAnimation(