Contours + alpha channel?

Hi All,

I'm using matplotlib (with agg backends) from recent svn:

In [63]: matplotlib.__version__
Out[63]: '0.87.4'

and I can't seem to get contour() or contourf() to utilize the
alpha keyword. No matter what value I set, alpha=1.0 on the
output. Alpha in general works fine, as the scatter_demo2.py
example gives very nicely alpha-channeled output.

Any ideas? Thanks a bunch,

Scott

···

--
--
Scott M. Ransom Address: NRAO
Phone: (434) 296-0320 520 Edgemont Rd.
email: sransom@...1237... Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989

Scott,

Please send a minimal example that I can use as a test case. This sounds vaguely familiar.

Thanks.

Eric

Scott Ransom wrote:

···

Hi All,

I'm using matplotlib (with agg backends) from recent svn:

In [63]: matplotlib.__version__
Out[63]: '0.87.4'

and I can't seem to get contour() or contourf() to utilize the
alpha keyword. No matter what value I set, alpha=1.0 on the
output. Alpha in general works fine, as the scatter_demo2.py
example gives very nicely alpha-channeled output.

Any ideas? Thanks a bunch,

Scott

Hi Eric,

This shows what I'm talking about:

···

--------------------
from pylab import *

delta = 0.025
x = arange(-3.0, 3.0, delta)
y = arange(-2.0, 2.0, delta)
X, Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)

contourf(X, Y, sin(Y)*cos(X),
         alpha=0.2)
hot()
contour(X, Y, Z, 6,
        linewidths=4,
        colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5'),
        alpha=0.4)
show()

-------------------

On Thursday 31 August 2006 13:50, Eric Firing wrote:

Scott,

Please send a minimal example that I can use as a test case. This
sounds vaguely familiar.

Thanks.

Eric

Scott Ransom wrote:
> Hi All,
>
> I'm using matplotlib (with agg backends) from recent svn:
>
> In [63]: matplotlib.__version__
> Out[63]: '0.87.4'
>
> and I can't seem to get contour() or contourf() to utilize the
> alpha keyword. No matter what value I set, alpha=1.0 on the
> output. Alpha in general works fine, as the scatter_demo2.py
> example gives very nicely alpha-channeled output.
>
> Any ideas? Thanks a bunch,
>
> Scott

--
Scott M. Ransom Address: NRAO
Phone: (434) 296-0320 520 Edgemont Rd.
email: sransom@...1237... Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989

Scott,

This is fixed now in svn. (I will probably go back shortly and make another change to improve efficiency.) There was a one-line bug in contour.py, but the fundamental problem was that colors.ColorConverter (which handles color inputs for collections, among other things) was stripping off the alpha value and replacing it with 1.0.

Thanks for highlighting the bug.

Eric

Scott Ransom wrote:

···

Hi Eric,

This shows what I'm talking about:

--------------------
from pylab import *

delta = 0.025
x = arange(-3.0, 3.0, delta)
y = arange(-2.0, 2.0, delta)
X, Y = meshgrid(x, y)
Z1 = bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)

contourf(X, Y, sin(Y)*cos(X),
         alpha=0.2)
hot()
contour(X, Y, Z, 6,
        linewidths=4,
        colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5'),
        alpha=0.4)
show()

-------------------

On Thursday 31 August 2006 13:50, Eric Firing wrote:

Scott,

Please send a minimal example that I can use as a test case. This
sounds vaguely familiar.

Thanks.

Eric

Scott Ransom wrote:

Hi All,

I'm using matplotlib (with agg backends) from recent svn:

In [63]: matplotlib.__version__
Out[63]: '0.87.4'

and I can't seem to get contour() or contourf() to utilize the
alpha keyword. No matter what value I set, alpha=1.0 on the
output. Alpha in general works fine, as the scatter_demo2.py
example gives very nicely alpha-channeled output.

Any ideas? Thanks a bunch,

Scott

Eric,
Now that this bug is sorted, will it enable pcolormesh to use alpha =
0 to not plot missing data?

--George.

···

On 01/09/06, Eric Firing <efiring@...202...> wrote:

Scott,

This is fixed now in svn. (I will probably go back shortly and make
another change to improve efficiency.) There was a one-line bug in
contour.py, but the fundamental problem was that colors.ColorConverter
(which handles color inputs for collections, among other things) was
stripping off the alpha value and replacing it with 1.0.

George Nurser wrote:

Scott,

This is fixed now in svn. (I will probably go back shortly and make
another change to improve efficiency.) There was a one-line bug in
contour.py, but the fundamental problem was that colors.ColorConverter
(which handles color inputs for collections, among other things) was
stripping off the alpha value and replacing it with 1.0.

Eric,
Now that this bug is sorted, will it enable pcolormesh to use alpha =
0 to not plot missing data?

George,

Unfortunately not--it is a completely different bug. A while ago I tracked the pcolormesh alpha bug down into the bowels of the quadmesh code, where it is making fairly low-level Agg calls. I didn't write quadmesh, I have never dealt with Agg directly, and I don't think I can afford the time that it would take for me to understand it--assuming I could. So, I've been unable to fix the pcolormesh alpha bug. I think it will require an Agg wizard, preferably one of the original quadmesh authors.

Eric

···

On 01/09/06, Eric Firing <efiring@...202...> wrote: