I am trying to draw some objects with the fabulous Matplotlib package for Python. These objects consist of points implemented with plt.scatter() and patches imp
Here is a version that uses only one call to Poly3DCollection, where edgecolors='k' controls the color of the line and facecolors='w' controls the color of the faces. Note how Matplotlib colors the edges behind the polygon in a lighter gray color.
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = [0, 2, 1, 1]
y = [0, 0, 1, 0]
z = [0, 0, 0, 1]
vertices = [[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]
tupleList = list(zip(x, y, z))
poly3d = [[tupleList[vertices[ix][iy]] for iy in range(len(vertices[0]))] for ix in range(len(vertices))]
ax.scatter(x,y,z)
ax.add_collection3d(Poly3DCollection(poly3d, edgecolors='k', facecolors='w', linewidths=1, alpha=0.5))
plt.show()
Caution The API for Poly3DCollection is rather confusing: the accepted keyword arguments are all of colors, edgecolor, edgecolors, facecolor, and facecolors (using aliases and decorators to define multiple kwargs to mean the same thing, where the "s" is optional for facecolor and edgecolor).