Making mesh skin transparent?

I wonder if mplot3d provides a way to alter the opacity of mesh face colors. Below is a simple example for creating a 3Dplot using mplot3D and marching_squares method.

import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection  from mpl_toolkits.mplot3d import Axes3D  # create 3D numpy array, called mask mask = np.zeros((3,3,3)) for i in np.arange(0,1):     for j in np.arange(0,1):         for k in np.arange(0,1):             mask[i,j,k] = 1  # use module (in this case, marching cubes) to find the vertices and faces of this 3D object  verts, faces, normals, values = marching_cubes_lewiner(mask) fig = plt.figure(figsize=(10, 10)) ax = fig.add_subplot(111, projection="3d")  ax.set_xlim(np.min(verts[:,0]), np.max(verts[:,0])) ax.set_ylim(np.min(verts[:,1]), np.max(verts[:,1]))  ax.set_zlim(np.min(verts[:,2]), np.max(verts[:,2]))  mesh = Poly3DCollection(verts[faces]) mesh.set_edgecolor('k') # set face color mesh.set_facecolor('r') ax.add_collection3d(mesh) plt.tight_layout() plt.show() 

Is there a function to set the face color as transparent (i.e. can you alter face opacity?) I searched around and have not found the right function, as yet.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.