Fundamentals 41 min read

Eight Python Libraries for Mesh, Point Cloud, and Data Visualization – Part 1

This article introduces eight Python libraries—Open3D, Trimesh, PyVista, Vedo, Pyrender, PlotOptiX, Polyscope, and Simple‑3dviz—detailing their installation, core APIs, and step‑by‑step code examples for visualizing meshes, point clouds, and multidimensional data.

Code DAO
Code DAO
Code DAO
Eight Python Libraries for Mesh, Point Cloud, and Data Visualization – Part 1

The article presents eight Python libraries for 3D visualization, mesh and point‑cloud processing, and data animation. It splits the discussion into two parts; this first part covers Open3D, Trimesh, PyVista, and Vedo.

Open3D

Open3D is a fast‑growing library built in C++ with full Python bindings. It targets 3D processing similar to OpenCV for vision and integrates with deep‑learning frameworks via Open3D‑ML. Installation (Python 3.8) is done with Anaconda:

conda create -n open3d_env python=3.8
conda activate open3d_env
pip install open3d

After installation, import open3d as o3d and print(o3d.__version__) verify the version. The io module loads meshes ( o3d.io.read_triangle_mesh) and point clouds ( o3d.io.read_point_cloud), optionally enabling post‑processing to retrieve textures and materials.

Example code loads an Angel statue mesh, prints vertices and triangles, and creates a visualizer:

import numpy as np
import open3d as o3d
mesh_path = 'mesh/angelStatue_lp.obj'
mesh = o3d.io.read_triangle_mesh(mesh_path, True)
print(mesh)
print('Vertices:')
print(np.asarray(mesh.vertices))
print('Triangles:')
print(np.asarray(mesh.triangles))

A Visualizer() object is created, a window is opened, the mesh and a sphere primitive are added, normals are computed, and the sphere is translated. An animation callback rotates both objects each frame:

def rotate_around(vis):
    R = mesh.get_rotation_matrix_from_xyz((0, np.deg2rad(2), 0))
    mesh.rotate(R, center=(0,0,0))
    R_sphere = sphere_mesh.get_rotation_matrix_from_xyz((0, np.deg2rad(-4), 0))
    sphere_mesh.rotate(R_sphere, center=(0,0,0))
    vis.update_geometry(mesh)
    vis.update_geometry(sphere_mesh)
    vis.update_renderer()

vis.register_animation_callback(rotate_around)
vis.run()
vis.destroy_window()

Open3D can also visualize multidimensional data; the article shows converting a weather CSV (temperature, humidity, month) into a NumPy array and rendering it as a point cloud.

Trimesh

Trimesh is a pure‑Python library for loading, analyzing, and visualizing meshes and point clouds. It is widely used for preprocessing 3D assets before statistical analysis or machine‑learning pipelines. Installation uses Anaconda and adds pyglet for interactive visualizations:

conda create -n trimesh_env python=3.8
conda activate trimesh_env
conda install numpy
pip install trimesh
pip install pyglet

Loading a mesh and creating a scene with a sphere primitive:

mesh_path = 'mesh/angelStatue_lp.obj'
mesh = trimesh.load(mesh_path)
sphere_mesh = trimesh.primitives.Sphere(radius=0.1)
sphere_mesh.visual.face_colors = [0,0,255,255]
s = trimesh.Scene([sphere_mesh, mesh])
print(s.graph.nodes)
s.show(callback=rotate_objects)

The callback rotate_objects builds a homogeneous transformation matrix using np.eye(4), applies sinusoidal translation to the sphere, and rotates the Angel mesh with trimesh.transformations.rotation_matrix. The scene is updated each frame.

Trimesh is also used to create a 3‑D bar chart of average monthly temperature. After grouping the CSV data with pandas, each month’s temperature generates a cylinder primitive whose height encodes the temperature and whose color is interpolated from blue (cold) to red (hot). The cylinders are positioned with custom transformation matrices and displayed via s.show(...).

PyVista

PyVista builds on VTK to provide a high‑level, Pythonic API for mesh analysis and 3‑D plotting. It runs on Linux, macOS, and Windows and requires Python 3.7+ and NumPy. Installation via conda‑forge:

conda create -n pyvista_env python=3.8
conda activate pyvista_env
conda install numpy
conda install -c conda-forge pyvista

For interactive, non‑blocking visualizations, pyvistaqt is installed and a BackgroundPlotter is used. Example code loads the Angel mesh, its texture, creates a sphere, adds a blue point light, and registers an update callback that rotates the mesh and sphere while moving the light to follow the sphere:

import pyvista as pv
from pyvistaqt import BackgroundPlotter
mesh = pv.read('mesh/angelStatue_lp.obj')
tex = pv.read_texture('mesh/angelStatue_lp.jpg')
p = BackgroundPlotter(window_size=(600,400))
p.camera_position = 'xy'
p.camera.clipping_range = (0,10)
sphere = pv.Sphere(radius=0.2, center=(0,0,1))
light = pv.Light((0,0,1), (0,0,0), 'blue')

p.add_mesh(mesh, name='angel', texture=tex)
p.add_mesh(sphere, pbr=True, metallic=0.7, roughness=0.2, diffuse=1)
p.add_light(light)

def update_scene():
    mesh.rotate_y(10, inplace=True)
    sphere.rotate_y(-10, inplace=True)
    light.position = sphere.center
    p.update()

p.add_callback(update_scene, interval=100)
p.show()
p.app.exec_()

PyVista also supports visualizing the same weather dataset as a 3‑D point cloud, adding scalar‑colored points, labels, and a rotating camera callback.

Vedo

Vedo (also called V3do) is another Python library built on VTK that focuses on scientific analysis and visualization of 3‑D objects, point clouds, and volumes. It requires VTK and NumPy and works on all major OSes. Installation via conda‑forge:

conda create -n vedo_env python=3.8
conda activate vedo_env
conda install numpy
conda install -c conda-forge vedo

After installation, import vedo and vedo.Sphere().show(axis=1) verify the setup. Vedo can load meshes, apply textures, set material properties, and create primitives such as boxes and spheres. Example code loads the Angel mesh, adds a texture, creates a floor box and a metallic sphere, and sets up two lights (one blue attached to the sphere, one white ambient):

mesh = vedo.load('mesh/angelStatue_lp.obj')
mesh.texture('mesh/angelStatue_lp.jpg')
mesh.lighting('default')
floor = vedo.Box(length=5, width=5, height=0.1).z(1).c('white').lighting('glossy')
floor.rotate(90, axis=(1,0,0))
sphere = vedo.Sphere(r=0.2).pos(1,0,0).lighting('metallic')
l1 = vedo.Light(sphere, c='b', intensity=2)
l2 = vedo.Light((1,2,1), c='w', intensity=1)
plt = vedo.Plotter(bg='blackboard')
plt.addShadows()
vedo.show(mesh, floor, sphere, l1, l2, interactive=0, bg='black')
plt.timerCallback('create', dt=10)
plt.addCallback('timer', rotate_objects)
plt.interactive().close()

The callback rotate_objects rotates the Angel mesh and sphere with rotateY, updates the blue light position to follow the sphere, and renders the scene each tick.

Overall, the article provides a comparative overview, installation guides, and concrete code snippets for each library, enabling readers to choose the tool that best fits their 3‑D visualization needs.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Pythonpoint-cloud3d-visualizationmeshopen3dpyvistatrimeshvedo
Code DAO
Written by

Code DAO

We deliver AI algorithm tutorials and the latest news, curated by a team of researchers from Peking University, Shanghai Jiao Tong University, Central South University, and leading AI companies such as Huawei, Kuaishou, and SenseTime. Join us in the AI alchemy—making life better!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.