Show Sidebar Hide Sidebar # 3D Isosurface Plots in Python

How to make 3D Isosurface Plots in Python with Plotly.

With go.Isosurface, you can plot isosurface contours of a scalar field value, which is defined on x, y and z coordinates.

#### Basic Isosurface¶

In this first example, we plot the isocontours of values isomin=2 and isomax=6. In addition, portions of the sides of the coordinate domains for which the value is between isomin and isomax (named the caps) are colored. Please rotate the figure to visualize both the internal surfaces and the caps surfaces on the sides.

In :
import plotly.graph_objects as go

fig= go.Figure(data=go.Isosurface(
x=[0,0,0,0,1,1,1,1],
y=[1,0,1,0,1,0,1,0],
z=[1,1,0,0,1,1,0,0],
value=[1,2,3,4,5,6,7,8],
isomin=2,
isomax=6,
))

fig.show()


### Removing caps when visualizing isosurfaces¶

For a clearer visualization of internal surfaces, it is possible to remove the caps (color-coded surfaces on the sides of the visualization domain). Caps are visible by default.

In :
import plotly.graph_objects as go
import numpy as np

X, Y, Z = np.mgrid[-5:5:40j, -5:5:40j, -5:5:40j]

# ellipsoid
values = X * X * 0.5 + Y * Y + Z * Z * 2

fig = go.Figure(data=go.Isosurface(
x=X.flatten(),
y=Y.flatten(),
z=Z.flatten(),
value=values.flatten(),
isomin=10,
isomax=40,
caps=dict(x_show=False, y_show=False)
))
fig.show()