I am trying to plot points drifting in the sea. The following code works, but plots all the points of the previous plots as well:
Duration = 6 #hours
plt.figure(figsize=(20,10))#20,10
map = Basemap(width=300000,height=300000,projection='lcc',
resolution='c',lat_0=51.25,lon_0=-4)#lat_0lon_0 is left under
map.drawmapboundary(fill_color='turquoise')
map.fillcontinents(color='white',lake_color='aqua')
map.drawcountries(linestyle='--')
x=[]
y=[]
for i in range (0,Duration):
x,y = map(Xpos1[i],Ypos1[i])
map.scatter(x, y, s=1, c='k', marker='o', label = 'Aurelia aurita', zorder=2)
plt.savefig('GIF10P%d' %i)
Xpos1 and Ypos1 are a list of masked arrays. Every array in the lists has a length of 10, so 10 points should be plotted in each map:
Xpos1=[[latitude0,lat1,lat2,lat3,..., lat9],
[latitude0,lat1,lat2,lat3,..., lat9],...]
This gives me six figures, I'll show you the first and last:
Every picture is supposed to have 10 points, but the last one is a combination of all the maps (so 60 points). How do I still get 6 maps with only 10 points each?
Edit: When I use the answer from matplotlib.pyplot will not forget previous plots - how can I flush/refresh? I get the error
ValueError: Can not reset the axes. You are probably trying to re-use an artist in more than one Axes which is not supported
A similar error pops up when I use the answer from: How to "clean the slate"? namely,
plt.clf()
plt.cla()#after plt.show()
Any help is deeply appreciated!