PyMesh3D
Basic Installation
This project for mesh render in data science.
1 2
| pip install --upgrade pip pip install pymesh3d
|
If you need mayavi backend.
1 2
| pip install mayavi pip install pyqt
|
Quick Start
1 2 3
| import pymesh import numpy as np import matplotlib.pyplot as plt
|
Look at the directory example for full example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
wkdir = "../../Render"
ey = np.load(wkdir + "/Ez.npy")[::2, ::50]
m, n = ey.shape[0], ey.shape[1] res = np.zeros([m, n, n]) pymesh.rotate(ey, res, ifhalf = False)
fig = plt.figure(figsize=(4, 3)) plt.contourf(res[:, int(n/2), :].T) cbar = plt.colorbar()
|

1 2 3 4 5 6 7
|
mesh = pymesh.get_iso_surf(res, contours_number = 4, cmap = "jet") color = pymesh.interp_color(mesh.iso_vals, cmap = "jet") mesh.export(wkdir + "test", "obj")
|
1 2 3 4 5
|
mesh = pymesh.Mesh.load(wkdir + "test", "obj")
|
1 2 3 4 5
| from mayavi import mlab
mlab_mesh = pymesh.iso_surface(mesh, colormap = "RdBu") mlab.colorbar() mlab.show()
|

1 2 3 4 5
|
surf = mesh.plt_trisurf(cmap = "jet") plt.colorbar(surf, orientation = 'horizontal') plt.tight_layout()
|
