` I struggle to set some transparency in an Axes3D plot with
series of 2D-slices generated with pcolor. In spite of trying to
set alpha, all the slices remain opaque. I’ve just posted the
issue on stackoverflow ,
where you can see an illustration of the problem. Would someone
have a workaround?
`
import numpy as np
``import matplotlib.pyplot as plt``
``from mpl_toolkits.mplot3d import Axes3D``
`` from matplotlib.collections import
PolyCollection``
````
``X, Y = np.meshgrid(x,y)``
````
``fig = plt.figure()``
``ax = fig.gca(projection='3d')``
````
``alpha = 0.8``
````
``for i in range(len(islices)):``
`` im = ax.pcolor(X,Y,u[islices[i],:,:])
That image -- the way the 0.45 layer is drawn as if it's in front of
the 0.40 layer -- illustrates a problem I've always had with Axes3D.
I didn't have trouble making them transparent, but Axes3D sometimes
makes the wrong decision about which layer is in front, so you get
the wrong translucency. I have an illustration of the problem at http://shallowsky.com/blog/programming/matplotlib-3d-collection.html
I always meant to file a bug on it but never did.
Thibaut, I'm not sure why your alpha values aren't working, but you
might want to compare my demo (linked from that page) to see
what's different, since the alpha is working for me.
The ordering problem is well-known and is a limitation of the 2D rendering engine of matplotlib. I call them “Escher Effects”. No need to file a bug report, there are plenty of discussions on ways to mitigate it in specific instances, but ultimately, if you need a complex 3D scene, you may need to use a true 3D rendering tool like mayavi or others. This is discussed on the mplot3d main page.