3D point visualization
Plot measurements with three numeric dimensions.
Plotly · Class
go.Scatter3d creates an interactive 3D scatter trace from x, y, and z coordinates. Use it when direct graph-object control is preferable to Plotly Express.
go.Scatter3d is a graph-object trace class for plotting individual data points in three-dimensional space. Supply coordinate arrays for x, y, and z, then configure how the trace is rendered with options such as mode, marker, and line before adding it to a Figure.
go.Scatter3d(x=x, y=y, z=z, mode=..., marker=..., line=...)| Name | Type | Description |
|---|---|---|
x | array-like | Coordinates along the first spatial axis. |
y | array-like | Coordinates along the second spatial axis. |
z | array-like | Coordinates along the third spatial axis. |
mode | string | Trace rendering mode, such as markers or lines. |
marker | object | Point appearance configuration. |
line | object | Connecting-line appearance configuration. |
A Scatter3d graph-object trace.
import plotly.graph_objects as go
fig = go.Figure(go.Scatter3d(
x=[1, 2, 3],
y=[2, 1, 3],
z=[0, 1, 2],
mode="markers+lines"
))
fig.show()Creates a 3D trace from matching x, y, and z coordinates, displaying both points and connecting segments.
Plot measurements with three numeric dimensions.
Show a path or sequence through space.
Encode an additional variable through point appearance.
Use go.Scatter3d when a lower-level graph-object trace is a better fit than Plotly Express. Construct it with x, y, and z coordinate data, then place it in a go.Figure.
Follow-up: How can a single trace show both points and connections? Set mode to a combination such as "markers+lines".
The three coordinate collections define positions in 3D space: x, y, and z. Rendering can be customized with trace attributes, including marker and line settings.
Follow-up: How would you color points by a numeric variable? Pass that variable through marker configuration and choose an appropriate colorscale.
The class is available from plotly.graph_objects and can be passed to go.Figure as trace data. The resulting figure can then be displayed with fig.show().
Follow-up: What should you consult for the complete attribute set? Use the Scatter3d function reference linked by the official documentation.
plotly.graph_objectsgo.Figurego.Scatterpx.scatter_3d