Nametag of data point in python animation code prints over and over -


so i'm struggeling problem, namely annotations don't refresh , stay in figure. i've tried ax.cla() (in init function , update_point function), doesn't seem work. code random numbers , not own data. i'm running script 10 datasets of 10 people walking. want see these people walked. can please me seemingly simple question?

my code:

import numpy np import matplotlib.pyplot plt import matplotlib.animation animation  x1 = np.linspace(0,1,50) y1 = x1 x2 = np.linspace(0,1,50) y2 = y1+1  print(max(x1)) print(x1[10],y1[0])  fig = plt.figure() ax = fig.add_subplot(111) ax.set_xlim(0, 1) ax.set_ylim(0, 2) point1, = ax.plot([x1[0]], [y1[0]], 'ro', label='data1') anno1 = plt.annotate("data1", xy=(x1[0], y1[0])) point2, = ax.plot([x2[0]], [y2[0]], 'bo', label='data2') anno2 = plt.annotate("data2", xy=(x2[0], y2[0]))  def init():     return point1, point2, anno1, anno2   def update_point(n):      point1.set_data(np.array([x1[n], y1[n]]))     anno1 = plt.annotate("data1", xy=(x1[n], y1[n]))     point2.set_data(np.array([x2[n], y2[n]]))     anno2 = plt.annotate("data2", xy=(x2[n], y2[n]))     return point1, point2, anno1, anno2,  ani = animation.funcanimation(fig, update_point, len(x1), interval=200)  plt.show() 


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -