def plot_hour():
alfa = np.linspace(np.pi*1/2, -3*1/2*np.pi, 13)
hours = np.array([12,1,2,3,4,5,6,7,8,9,10,11,12])
print(hours)
print(alfa)
h = np.stack((alfa, hours), axis=1)
print(h)
flag = 0
for item in np.nditer(h):
#print(flag,item)
if(flag==1):
theta = lastItem
nr = str(item)
r=1.2
ax.text(r*np.cos(theta),r*np.sin(theta),str(nr),color="green",fontsize=10,horizontalalignment='center')
lastItem = item
if(flag==0):flag=1
elif(flag==1):flag=0
# animation function. This is called sequentially
def animate(i):
x = [0, np.cos(i)]
y = [0, np.sin(i)]
line.set_data(x, y)
return (line,)
delay=1000
alfa = np.linspace(np.pi*1/2, -3*1/2*np.pi, 13)
ax.scatter(np.cos(alfa),np.sin(alfa))
plot_hour()
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=alfa, interval=delay, blit=True)
HTML(anim.to_html5_video())
# save the animation as an mp4. This requires ffmpeg or mencoder to be
# installed. The extra_args ensure that the x264 codec is used, so that
# the video can be embedded in html5. You may need to adjust this for
# your system: for more information, see
# http://matplotlib.sourceforge.net/api/animation_api.html
#anim.save('movie.mp4', fps=30, extra_args=['-vcodec', 'libx264']
#or
# save the animation as mp4 video file
#anim.save('animated_coil.mp4', writer = 'ffmpeg', fps = 30)
# show the plot
#plt.show()