On Sat, Nov 15, 2008 at 3:23 PM, Hrafnkell Pálsson <[EMAIL PROTECTED]> wrote: > > Hi > I haven't managed to save a plot background into buffer to be able to > restore it later. > I use matplotlib to draw weather maps (see www.belgingur.is), and though the > weather constantly changes the outlines of the countries are the same for > every picture. > Currently I plot the coastlines anew for every picture, which is kinda *not > smart*.
Have you tried the "copy from bbox" / "restore_region" methods. Draw just what you want to save, and use "copy_from_bbox". Later when you want to plot something new, do a "restore_region" onto a clean canvas and then plot the new stuff on top: * background = canvas.copy_from_bbox(ax.bbox) - copy the region in ax.bbox into a pixel buffer and return it in an object type of your choosing. bbox is a matplotlib BBox instance from the transforms module. background is not used by the matplotlib frontend, but it stores it and passes it back to the backend in the restore_region method. You will probably want to store not only the pixel buffer but the rectangular region of the canvas from whence it came in the background object. * canvas.restore_region(background) - restore the region copied above to the canvas. * canvas.blit(bbox) - transfer the pixel buffer in region bounded by bbox to the canvas. Search the examples for "copy_from_bbox" on the web site http://matplotlib.sourceforge.net/search.html If you are still having troubles, let me know and I can give more help. JDH ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users