plotting an array of enumerated values

they will not be transparent. If you need transparent

    > masked regions, then try pcolor instead of imshow. Pcolor
    > plots nothing at all in masked cells. Pcolormesh, on the
    > other hand, is like imshow in plotting the assigned bad
    > color and in using a single alpha for everything.

I'm confused about the comments about alpha not working on imshow --
can you elaborate. On the agg backend at least, the alpha channel is
respected in imshow, eg examples/layer_images.py. Is there a reason
it does not (or should not) work in the masked example?

JDH

John Hunter wrote:

"Eric" == Eric Firing <efiring@...202...> writes:

    > they will not be transparent. If you need transparent
    > masked regions, then try pcolor instead of imshow. Pcolor
    > plots nothing at all in masked cells. Pcolormesh, on the
    > other hand, is like imshow in plotting the assigned bad
    > color and in using a single alpha for everything.

I'm confused about the comments about alpha not working on imshow --
can you elaborate. On the agg backend at least, the alpha channel is
respected in imshow, eg examples/layer_images.py. Is there a reason
it does not (or should not) work in the masked example?

John,

I don't know why it doesn't work; I know only that in my example, it doesn't work as I perhaps naively think it should. My interpretation of alpha is that if alpha is zero in any colored region, and if nothing else is drawn on top, then the background should show through; that is, the r,g,b values in the r,g,b,a tuple for a region should have no effect if a is zero. If you uncomment
#cmap.set_bad((1,1,1,0)
in my example, you will find that the masked region is white; and if you change the rgb part of that tuple, it takes on that color, regardless of alpha.

The Colormap.__call__() is trying to respect the individual alphas of the special colors (bad, under, over) while setting a uniform alpha for the normal colors, but somewhere along the line this is not working as intended. I ran into this when I wrote the code for the special colors, and I left a comment to that effect, but apart from taking another look just now I have not tried to track it down. The behavior is the same in imshow and in pcolormesh. I tried to work around it by setting the default bad color to white. The difference in pcolor is that it draws nothing at all in the masked region, so one sees the gray background.

Eric