Skip to content

Commit

Permalink
WIP: tidy up animate function based on plot2d_polygon, add comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrhardman committed Feb 10, 2025
1 parent dbd07df commit 367c225
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions xbout/plotting/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,19 +833,12 @@ def animate_polygon(
colors = da.data[0,:,:].flatten()
polys.set_array(colors)
ax.add_collection(polys)

#def update(frame):
# # for each frame, update the data stored on each artist.
# colors = da.data[frame,:,:].flatten()
# polys.set_array(colors)
# return polys
# function to update the data plotted
# assuming data in shape (t,x,y)
def update(frame):
colors = da.data[frame,:,:].flatten()
polys.set_array(colors)
print(da.data[0,0,0].compute())
print(frame)
#update(0)


if add_colorbar:
# This produces a "foolproof" colorbar which
# is always the height of the plot
Expand All @@ -869,13 +862,8 @@ def update(frame):

if targets:
plot_targets(da, ax, x="R", y="Z", hatching=add_limiter_hatching)

#print(np.shape(da.data))
#colors = da.data[0,:,:].flatten()
#polys.set_array(colors)
#ax.add_collection(polys)


ani = matplotlib.animation.FuncAnimation(fig=fig, func=update, frames=np.shape(da.data)[0], interval=3000)

# make the animation by using FuncAnimation and update() to generate frames
ani = matplotlib.animation.FuncAnimation(fig=fig, func=update, frames=np.shape(da.data)[0], interval=30)
return ani

0 comments on commit 367c225

Please sign in to comment.