I started off with the Polygon plotting example of the basemap toolkit as I
want to visualize Radar data with GoogleEarth.
I have a polygon shapefile and another data file in which I have one value
for each of the polygons.
I do the basemap.read_shapefile and the axes.add_patch stuff once in the
beginning, keeping a list of the polygon-instances.
Then, for each data file I set the face color of the polygons according to
their respective value and call pyplot.savefig() to save to a png file. This
way I have to do the time and memory consuming task of reading the shapefile
and producing the polygon patches (~40000) only once at the beginning.
That worked splendidly.
Now I wanted some data values to be transparent (so that only rainfall is
actually drawn). So I thought about using set_visible(None) on the
That seems to work as well, but now I have the problem, that wherever a
polygon becomes invisible, the patch from the previous run remains visible.
So apparently, the figure's canvas (or whatever object is responsible for
the final image pixels) is not initialized between subsequent calls to
I searched a bit through the code of figure.py, backend_bases.py,
backend_agg.py but didn't find any method that looked like it would erase
If I do clf() then savefig() always saves the same image over and over
again. I suppose it's because no new data is drawn to the canvas in this
Any ideas, how to solve this?
Thank you for your help