From 2ba955dfe495ad93e21644e54c2d140dd587ea4a Mon Sep 17 00:00:00 2001 From: Peter Stahlecker Date: Thu, 19 Sep 2024 08:21:52 +0200 Subject: [PATCH] code to reduce frame simplified --- .../plot_pendulum_swing_up_fixed_duration.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/examples-gallery/plot_pendulum_swing_up_fixed_duration.py b/examples-gallery/plot_pendulum_swing_up_fixed_duration.py index ef166c1..ba00326 100644 --- a/examples-gallery/plot_pendulum_swing_up_fixed_duration.py +++ b/examples-gallery/plot_pendulum_swing_up_fixed_duration.py @@ -1,4 +1,3 @@ -# %% """ Fixed Duration Pendulum Swing Up ================================ @@ -104,14 +103,7 @@ # %% # Animate the pendulum swing up. -solution1 = [] -for i in range(len(solution)): - if i % 5 == 0: - solution1.append(solution[i]) -solution1.append(solution[-1]) -solution = solution1 -num_nodes = int(len(solution)/3) -time = np.linspace(0.0, duration, num=num_nodes) +time = np.linspace(0, duration, num_nodes) angle = solution[:num_nodes] fig = plt.figure() @@ -139,7 +131,7 @@ def animate(i): return line, time_text -ani = animation.FuncAnimation(fig, animate, range(num_nodes), +ani = animation.FuncAnimation(fig, animate, range(0, num_nodes, 5), interval=int(interval_value*1000*5), blit=True, init_func=init)