@@ -833,19 +833,12 @@ def animate_polygon(
833833 colors = da .data [0 ,:,:].flatten ()
834834 polys .set_array (colors )
835835 ax .add_collection (polys )
836-
837- #def update(frame):
838- # # for each frame, update the data stored on each artist.
839- # colors = da.data[frame,:,:].flatten()
840- # polys.set_array(colors)
841- # return polys
836+ # function to update the data plotted
837+ # assuming data in shape (t,x,y)
842838 def update (frame ):
843839 colors = da .data [frame ,:,:].flatten ()
844840 polys .set_array (colors )
845- print (da .data [0 ,0 ,0 ].compute ())
846- print (frame )
847- #update(0)
848-
841+
849842 if add_colorbar :
850843 # This produces a "foolproof" colorbar which
851844 # is always the height of the plot
@@ -869,13 +862,8 @@ def update(frame):
869862
870863 if targets :
871864 plot_targets (da , ax , x = "R" , y = "Z" , hatching = add_limiter_hatching )
872-
873- #print(np.shape(da.data))
874- #colors = da.data[0,:,:].flatten()
875- #polys.set_array(colors)
876- #ax.add_collection(polys)
877-
878-
879- ani = matplotlib .animation .FuncAnimation (fig = fig , func = update , frames = np .shape (da .data )[0 ], interval = 3000 )
865+
866+ # make the animation by using FuncAnimation and update() to generate frames
867+ ani = matplotlib .animation .FuncAnimation (fig = fig , func = update , frames = np .shape (da .data )[0 ], interval = 30 )
880868 return ani
881869
0 commit comments