Python Forum
Problem with animation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with animation
#1
I have this code for animating two lines
def animate(i):
   global GLOBAL_TARGET
   global GLOBAL_RESULT
   if i > 19:
       i = 19
   x = np.linspace(0,i, i)
   xx = np.linspace(i, 2*i, i)
   y = GLOBAL_RESULT[0:i]
   print i
   yy = GLOBAL_TARGET[0:i]
   try:
       maxNumber = np.amax(yy)
       for i in range(0,len(yy)):
           yy[i] = i/float(maxNumber/4.0)
   except Exception as e:
       maxNumber = 1000
       for i in range(0,len(yy)):
           yy[i] = i/float(maxNumber/4.0)
       pass
   #yy = yy / float(max(yy)) * 4
   #yy = range(11, 17)
   print yy
   print len(yy)
   print y
   print len(y)
   line.set_data([x,x],[y, yy])
   return line,
....
....
....
anim = animation.FuncAnimation(fig, animate, init_func=init,
                              frames=20, interval=100, blit=True)
but only one line is drawn why?
Moderator Larz60+: Changed icode tags to python tags -- you used wrong tags Also remove formatting first
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020