-
Notifications
You must be signed in to change notification settings - Fork 1
/
testbasemapanim.py
32 lines (27 loc) · 963 Bytes
/
testbasemapanim.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0,
lat_0=0, lon_0=-130)
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color = 'gray')
map.drawmapboundary()
map.drawmeridians(np.arange(0, 360, 30))
map.drawparallels(np.arange(-90, 90, 30))
x,y = map(0, 0)
point = map.plot(x, y, 'ro', markersize=5)[0]
def init():
point.set_data([], [])
return point,
# animation function. This is called sequentially
def animate(i):
lons, lats = np.random.random_integers(-130, 130, 2)
x, y = map(lons, lats)
point.set_data(x, y)
return point,
# call the animator. blit=True means only re-draw the parts that have changed.
anim = animation.FuncAnimation(plt.gcf(), animate, init_func=init,
frames=20, interval=500, blit=False)
plt.show()