Inspect 3D relationships
Exploratory analysis of three numeric dimensions.
Plotly · Function
Creates an interactive three-dimensional scatter plot, with each data-frame row represented as a point. Map columns or arrays to x, y, and z, then optionally encode additional variables through color, size, symbol, and other Plotly Express options.
px.scatter_3d maps rows from an optional data frame into points in three-dimensional space. The x, y, and z arguments select the three coordinates, while optional encodings such as color, size, symbol, and animation settings control additional visual dimensions and interaction.
plotly.express.scatter_3d(data_frame=None, x=None, y=None, z=None, color=None, symbol=None, size=None, text=None, hover_name=None, hover_data=None, custom_data=None, error_x=None, error_y=None, error_z=None, animation_frame=None, animation_group=None, category_orders=None, labels=None, size_max=None, color_discrete_sequence=None, color_discrete_map=None, color_continuous_scale=None, range_color=None, color_continuous_midpoint=None, opacity=None, log_x=False, log_y=False, log_z=False, range_x=None, range_y=None, range_z=None, title=None, template=None, width=None, height=None)| Name | Type | Description |
|---|---|---|
data_frame | DataFrame or array-like | Optional data frame supplying the plotted data. |
x | str, int, Series, array-like, or None | Column or array used for the x coordinate. |
y | str, int, Series, array-like, or None | Column or array used for the y coordinate. |
z | str, int, Series, array-like, or None | Column or array used for the z coordinate. |
color | str, int, Series, array-like, or None | Optional grouping or continuous color encoding. |
size | str, int, Series, array-like, or None | Optional marker-size encoding. |
... | various keyword arguments | Additional Plotly Express options such as symbol, hover data, animation, labels, and layout settings. |
A Plotly figure representing the 3D scatter plot.
import plotly.express as px
fig = px.scatter_3d(
px.data.iris(),
x="sepal_length",
y="sepal_width",
z="petal_width",
color="species",
)
fig.show()Creates an interactive 3D scatter plot from Plotly Express's built-in iris dataset.
Exploratory analysis of three numeric dimensions.
Add a categorical or numeric variable to point appearance.
Explore observations across a time or category sequence.
px.scatter_3d create, and how are coordinates assigned?It is a Plotly Express function that creates a 3D scatter plot, representing each data-frame row as a point. The three spatial coordinates are supplied through x, y, and z.
Follow-up: How would you represent a fourth variable? Use an encoding such as color, size, symbol, or an animation-related parameter rather than another spatial axis.
Pass a data frame as the first argument and identify its columns with x, y, and z. A categorical column can be mapped with color, as in the documented iris example.
Follow-up: How can the resulting chart be customized after creation? Update the returned figure's traces or layout with methods such as fig.update.
px.scatter_3d be customized?The function returns a Plotly figure object, which can be displayed with fig.show(). Styling can be supplied through supported function parameters or applied afterward through figure and trace updates.
Follow-up: When would you use the lower-level API? Use a Scatter3d graph-object trace when direct control over trace attributes is required.
scatterscatter_3dscatter_matrixScatter3d