Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Plotly · Class

go.Scatter3d

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.

How it works

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.

Syntax

go.Scatter3d(x=x, y=y, z=z, mode=..., marker=..., line=...)

Parameters

NameTypeDescription
xarray-likeCoordinates along the first spatial axis.
yarray-likeCoordinates along the second spatial axis.
zarray-likeCoordinates along the third spatial axis.
modestringTrace rendering mode, such as markers or lines.
markerobjectPoint appearance configuration.
lineobjectConnecting-line appearance configuration.

Returns

A Scatter3d graph-object trace.

Key points

  • Import the class through plotly.graph_objects when you need direct control over the trace.
  • Each x, y, and z triplet represents one plotted location in 3D.
  • Build a Figure with the trace in its data collection.
  • The dedicated Scatter3d reference is the place to inspect the full set of chart attributes.

Common mistakes

  • This is a trace for individual 3D data, not a general-purpose 3D surface or volume representation.

Example: Basic 3D scatter 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.

When to use it

3D point visualization

Plot measurements with three numeric dimensions.

Connected 3D trajectories

Show a path or sequence through space.

3D bubble or color maps

Encode an additional variable through point appearance.

Interview questions

QWhen would you choose go.Scatter3d?

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".

QWhat data does the class require?

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.

QHow is a Scatter3d trace displayed?

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_objects
  • go.Figure
  • go.Scatter
  • px.scatter_3d

Source: 3D Scatter Plots in Python. Checked 2026-10-15.