In my quest to somehow get 3D polygons to actually plot, I came across the following script (EDIT: modified slightly): Plotting 3D Polygons in python-matplotlib
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.collections import Poly3DCollection
import matplotlib.pyplot as plt
fig = plt.figure()
ax = Axes3D(fig)
x = [0,1,1,0]
y = [0,0,1,1]
z = [0,1,0,1]
verts = [zip(x, y,z)]
ax.add_collection3d(Poly3DCollection(verts),zs=z)
plt.show()
But when I run that, I get the following error message:
TypeError: object of type 'zip' has no len()
It seems that this may be a Python 2 vs. 3 thing, as I am running in Python 3, and that post is five years old. So I changed the third-to-last line to:
verts = list(zip(x, y, z))
Now verts shows up in the variable list, but I still get an error:
TypeError: zip argument #1 must support iteration
What? How do I fix this?