I am creating a series of lat/long scatterplots on a map from basemap. I am planning on creating thousands of plot, with different lat/long data. To save time I wanted to draw the map overlay only once:
map = Basemap(epsg=3395, projection='merc', lat_0=59.45, lon_0=10.5,
resolution = 'h',
llcrnrlon=minlong, llcrnrlat=minlat,
urcrnrlon=maxlong, urcrnrlat=maxlat
map.arcgisimage(service='ESRI_Imagery_World_2D', xpixels=3000, verbose=True)
However, I find no way of clearing my previous scatterplot before plotting a new one.
for each set in sets:
x = set[0]
y = set[1]
x,y = map(x,y)
plt.scatter(x,y, s=2.5, alpha=1, color=c, edgecolors='none')
plt.savefig('title.png', format='png', bbox_inches='tight', dpi=500)
If I do the following:
plt.clf()
or
plt.close()
I have to redraw my map. If I don't have anything, the scatter plot from the previous iteration are plotted. So how do I remove all scatterplot data, but keeping the map data?
scat, = plt.scatter([],[], s=2.5, alpha=1, color=c, edgecolors='none') TypeError: 'PathCollection' object is not iterable
– Lawanda