Как обеспечить несколько аннотаций для разных точек на определенном кадре в анимации. Например, я строю пять точек на карте, и мне нужно пометить их как A, B, C, D и E.
import mpl_toolkits
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
from matplotlib import pyplot as plt
from matplotlib import animation
import numpy as np
map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0,
lat_0=0, lon_0=-130)
x,y = map(0,0)
point = map.plot(x, y, 'ro', markersize=4)[0]
def init():
point.set_data([], [])
return point,
def animate(i):
lon = np.random.random_integers(-130,130, 5)
lat = np.random.random_integers(-130,130, 5)
x, y = map(lon, lat)
point.set_data(x, y)
annotations = np.array('A','B','C','D','E')
return point, annotations
anim = animation.FuncAnimation(plt.gcf(), animate, init_func= init, frames= 100,interval= 500, blit=True)