+ from mpl_toolkits.mplot3d import Axes3D
+ from mpl_toolkits.mplot3d.art3d import Poly3DCollection
+ faces = self.faces()
+ fig = plt.figure()
+ ax = Axes3D(fig)
+ for face in faces:
+ points = []
+ vertices = Polyhedron._sort_polygon_3d(face)
+ for verts in vertices:
+ pairs=()
+ for coordinate, point in verts.coordinates():
+ pairs = pairs + (float(point),)
+ points.append(pairs)
+ collection = Poly3DCollection([points], alpha=0.7)
+ face_color = [0.5, 0.5, 1] # alternative: matplotlib.colors.rgb2hex([0.5, 0.5, 1])
+ collection.set_facecolor(face_color)
+ ax.add_collection3d(collection)
+ ax.set_xlabel('X')
+ ax.set_xlim(0, 5)
+ ax.set_ylabel('Y')
+ ax.set_ylim(0, 5)
+ ax.set_zlabel('Z')
+ ax.set_zlim(0, 5)
+ plt.grid()
+ plt.show()