How to control transparency over a 2D image in pylab? I would like to give two sets of values (X,Y,Z,T) , where X,Y are arrays of positions, Z is the color value, and T is transparency for a function like imshow , but it seems that the function only accepts an alpha scalar . As a specific example, consider the code below that tries to display two Gaussians. The closer the value is to zero, the more transparent I would like the chart to be.
from pylab import * side = linspace(-1,1,100) X,Y = meshgrid(side,side) extent = (-1,1,-1,1) Z1 = exp(-((X+.5)**2+Y**2)) Z2 = exp(-((X-.5)**2+(Y+.2)**2)) imshow(Z1, cmap=cm.hsv, alpha=.6, extent=extent) imshow(Z2, cmap=cm.hsv, alpha=.6, extent=extent) show()
Note. I'm not looking for a Z1 + Z2 plot (that would be trivial), but for a general way, specify alpha blending in the image.
python matplotlib alphablending
Hooked
source share