Interactive 3D Plots with Plotly

By Thomas Weng on December 23, 2022

I’ve recently had to plot a lot of 3D elements like point clouds and meshes for my research. Compared to 2D plots, 3D plots benefit greatly from interaction: translating and rotating the plot gives a better sense of the geometry of elements in the plot. I’ve found that plotly is the easiest and most responsive tool for interactive 3D plots, and this post is a primer on how I make them.

Visualizing meshes with plotly

Below is an example of a sphere rendered with Python and plotly.

The code is straightforward: pass the vertices and faces of a mesh to plotly’s create_trisurf() function.

Adding other elements to the same plot

Use the add_trace() function to add other elemnts, e.g. a point cloud, to the same figure.