I am plotting a scatter plot on a Basemap. However, the data with this scatter plot changes based on user input. I would like to clear the data (only the data -- not the entire basemap figure) and re-plot new scatter points.
This question is similar but was not answered (http://stackoverflow.com/questions/8429693/python-copy-basemap-or-remove-data-from-figure)
Currently I am closing the figure with clf(); however, this requires me to re-draw the entire basemap and scatter plot together. On top of this, I am doing all of the redrawing inside of a wx panel. The basemap redraw takes too long and am hoping that there is an easy way to simply re-plot scatter points only.
#Setting up Map Figure
self.figure = Figure(None,dpi=75)
self.canvas = FigureCanvas(self.PlotPanel, -1, self.figure)
self.axes = self.figure.add_axes([0,0,1,1],frameon=False)
self.SetColor( (255,255,255) )
#Basemap Setup
self.map = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
lon_0=-95, resolution='h', area_thresh=10000,ax=self.axes)
self.map.drawcoastlines()
self.map.drawcountries()
self.map.drawstates()
self.figure.canvas.draw()
#Set up Scatter Plot
m = Basemap(llcrnrlon=-119, llcrnrlat=22, urcrnrlon=-64,
urcrnrlat=49, projection='lcc', lat_1=33, lat_2=45,
lon_0=-95, resolution='h', area_thresh=10000,ax=self.axes)
x,y=m(Long,Lat)
#Scatter Plot (they plot the same thing)
self.map.plot(x,y,'ro')
self.map.scatter(x,y,90)
self.figure.canvas.draw()
Then I do an some type of update on my (x,y)...
#Clear the Basemap and scatter plot figures
self.figure.clf()
Then I repeat all of the above code. (I also have to redo my box sizers for my panel -- I did not include these).
Thanks!