3D Scatter Plots
Use 3D carefully
Section titled “Use 3D carefully”3D plots can look impressive but are often harder to interpret than they seem — a screen is 2D, so any 3D chart is really a projection, and projections distort distance and depth judgment. Two points that look close together might be far apart along the axis pointing “into” the screen.
Use 3D when:
- You genuinely need three continuous numeric variables plotted together
- Interaction (rotate/zoom) helps understanding, and the reader will actually rotate it
- Two 2D scatter plots (or a bubble chart) can’t tell the same story
If you just want to add a third variable to a 2D scatter, prefer color or bubble size (see the previous two pages) — it’s usually clearer than forcing a third spatial axis.
Example
Section titled “Example”import pandas as pd
import plotly.express as px
df = pd.DataFrame({
"x": [1, 2, 3, 4, 5],
"y": [10, 6, 8, 4, 7],
"z": [100, 120, 90, 150, 110],
"group": ["A", "A", "B", "B", "A"],
})
fig = px.scatter_3d(df, x="x", y="y", z="z", color="group", title="3D scatter")
fig.show()In the rendered chart, dragging rotates the camera and scrolling zooms — that interactivity is what makes a 3D plot usable at all; a static screenshot of the same figure often hides more than it reveals.
- Rotate before you conclude anything — a single static angle can hide clusters or trends.
- Prefer
scatter_3donly when a 2D-plus-color/size chart genuinely loses information. - Heavy point counts get cluttered fast in 3D; consider sampling or aggregating first.
flowchart TD
A["Need to show 3 numeric variables"] --> B{"Can color or bubble size
carry the 3rd variable?"}
B -- "Yes" --> C["Use 2D scatter/bubble chart
(easier to read, no rotation needed)"]
B -- "No, spatial depth matters" --> D["Use scatter_3d
and expect the reader to rotate it"]
Continue to: Creating Dashboards with Plotly to combine multiple charts into one view.
🧪 Try It Yourself
Section titled “🧪 Try It Yourself”Exercise 1 – Build a 3D Scatter
Section titled “Exercise 1 – Build a 3D Scatter”Exercise 2 – Color the Third Group
Section titled “Exercise 2 – Color the Third Group”Exercise 3 – When to Avoid 3D
Section titled “Exercise 3 – When to Avoid 3D”pch.coffeeTagline
pch.coffeeCtapch.feedbackHeading
pch.feedbackSubheading