On Thu, Sep 2, 2010 at 2:15 AM, Mitesh Patel <qed...@gmail.com> wrote:
> Hello,
>
> Is it possible to specify both an alpha level and a background color so
> that an entire saved image has a uniform transparency and color?  For
> example, with matplotlib 1.0.0, this script yields the attached image:
>
> from matplotlib.pyplot import figure, savefig, show
>
> fig = figure()
> ax = fig.add_subplot(111)
> ax.plot([1,2,3])
>
> fig.patch.set_alpha(0.5)
> for ax in fig.axes:
>    ax.patch.set_alpha(0.5)
>
> fig.patch.set_facecolor('red')
> for ax in fig.axes:
>    ax.patch.set_facecolor('red')
>
> savefig('test.png', facecolor='red')
>
>
> In particular, the areas inside and outside the axes have different
> transparency level and color.  Perhaps I'm over/mis/ab-using the options
> here?

It's not that they're not uniform--you're seeing alpha blending
between the figure patch and the axes patch. Within the axes, both are
being rendered and blended together. This is more readily apparent if
you use blue for the axes patch, as I did for the attached image. When
the red and blue are blended together, you end up with purple. If you
want it all uniform, you'd be better off setting the axes patch to an
alpha of 0.0.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

<<attachment: test.png>>

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to