python - Having trouble animating annotations on matplotlib plot -


first, let me show original plot looks like:

enter image description here

there 5 arrows there , i'd create animation show each of arrows, 1 @ time. using this tutorial produced following code:

fig, ax = plt.subplots(figsize=(11,11)) #ax.scatter(df.pickup_longitude,df.pickup_latitude,   #           c = df.pickup_cluster, cmap = "spectral",marker = '.', alpha = 0.01) ax.scatter(ave_cluster_loc["pickup_longitude"],ave_cluster_loc["pickup_latitude"],marker = '.')  index, row in ave_cluster_loc.iterrows():         ax.annotate(index, (row["pickup_longitude"],row["pickup_latitude"]))  annot,  = ax.arrow([], [], [], [],head_width = 0.005, head_length = 0.005)  def init():     annot.set_data([], [], [], [])     return line,  def animate(i):     annot.set_data(ave_cluster_loc.loc[i[0]].pickup_longitude, ave_cluster_loc.loc[i[0]].pickup_latitude,     ave_cluster_loc.loc[i[1]].pickup_longitude - ave_cluster_loc.loc[i[0]].pickup_longitude,      ave_cluster_loc.loc[i[1]].pickup_latitude - ave_cluster_loc.loc[i[0]].pickup_latitude)     return line,  anim  = animation.funcanimation(fig, animate, init_func=init,                                frames=len(top_pairs_index), interval=1)  ax.set_xlim(xlim)  ax.set_ylim(ylim) 

i valueerror: 'vertices' must 2d list or array shape nx2 error i'm not quite sure why. feel i'm following format of tutorial. appreciated.

here data set coordinates in case:

(-73.984718153352205, 40.759775939056098) (-74.011729441578112, 40.713087221779695) (-73.976949023252516, 40.76179427184185) (-74.011729441578112, 40.713087221779695) (-73.99020657228111, 40.749741468764995) 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -