I have a Trimesh object and I can't figure out how to plot it. My goal is something like the Axes3D.plot_trisurf() function from mplot3d would produce (see below). The Trimesh object even has an attribute containing the faces, but I don't know where to get the coordinates of the grid points.
Thanks for any idea!
You can just do this, where mesh
is your Trimesh object:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_trisurf(mesh.vertices[:, 0], mesh.vertices[:,1], triangles=mesh.faces, Z=mesh.vertices[:,2])
plt.show()
You may have to play with the scale, aspect, rotation, etc.