Python Forum
Problem with animation - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: Problem with animation (/thread-2742.html)



Problem with animation - jdewk - Apr-06-2017

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