Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Hi,
I'm trying to do a 3D plot with semi-transparent polyhedrons using mplot3d, but the setting of the alpha value has no effect. Here's the code I'm trying,
import mpl_toolkits.mplot3d as a3
import matplotlib.colors as colors
import pylab as pl
ax = a3.Axes3D(pl.figure())
color = colors.rgb2hex(sp.rand(3))
color = (0.,1.,0.,0.2) # but this works!
side1 = [[0.,0.,0.],[0.,0.,1.],[0.,1.,1.],[0.,1.,0.]]
tri = a3.art3d.Poly3DCollection([side1])
tri.set_facecolor(color)
tri.set_edgecolor('k')
tri.set_alpha(0.2) # HAS NO EFFECT
ax.add_collection3d(tri)
side2 = [[0.,0.,0.],[1.,0.,0.],[1.,1.,0.],[0.,1.,0.]]
tri = a3.art3d.Poly3DCollection([side2])
tri.set_facecolor(color)
tri.set_edgecolor('k')
tri.set_alpha(0.2)
ax.add_collection3d(tri)
pl.show()
Apparently, the tri.set_alpha sentences have no effect, and the pannels show solid. Changing color for an rgba tupla works, nonetheless (the commented line).
Cheers,
Ruyman