Hi all, I'd like use matplotlib to draw shapes on a
> transparent background using the Agg backend to save .png
> files. Is this possible?
> I've tried
There is a vestigial limitation from the bad old days when we didn't
have an alpha channel. For polyons, there is no place holder for a
separate alpha channel for the edge and face. The way to do this
right is to simply replace all rgb instances throughout the library
with rgba, but this is a fair amount of work that touches the entire
library. What I am doing currently is sharing the alpha attribute
between edge and face for polygons.
So setting alpha=0 *should work. What backend and version are you
using? Rectangle calls gc.set_alpha before calling draw_polygon in
patches.Patch. In _backend_agg.RendererAgg.draw_polygon, the alpha
attribute for the face is taken from the edge which gets it from the
gc (around line 204 in _backend_agg). I say all this just because
f = figure(1, facecolor='r')
does work for me using Agg and the latest matplotlib.
What backend and version are you using?
That said, the best way to do this is to add a frameon attribute for
figures, because this will be respected across backends including
those who don't understand alpha. This way you can say
f = figure(1, frameon=False)
I checked this into CVS.
from my read of the code *it should* work, and indeed, in my tests
> This seems to get halfway, but there's still (opaque)
> white drawn in the background.
> Is there a "recommended way", and, if so, what is it?
> Otherwise, can we improve matplotlib to allow drawing on
> transparent backgrounds?
> Cheers! Andrew
> This SF.Net email is sponsored by: Oracle 10g Get
> certified on the hottest thing ever to hit the
> market... Oracle 10g. Take an Oracle 10g class now, and
> we'll give you the exam FREE.
> Matplotlib-users mailing list