Skip to content

3D Scatter Plots

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

3D Scatter
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()
3D Scatter
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.

sketch A 3D scatter, projected onto a 2D screen p5.js
Points sit at (x, y, z); depth (z) is faked here with an isometric-style projection and size/brightness falloff.

Tips

  • Rotate before you conclude anything — a single static angle can hide clusters or trends.
  • Prefer scatter_3dscatter_3d only when a 2D-plus-color/size chart genuinely loses information.
  • Heavy point counts get cluttered fast in 3D; consider sampling or aggregating first.
diagram Should this be a 3D scatter? mermaid
3D adds real value only when a 2D chart with color or size can't capture the pattern.

Next

Continue to: Creating Dashboards with Plotly to combine multiple charts into one view.

🧪 Try It Yourself

Exercise 1 – Build a 3D Scatter

Exercise 2 – Color the Third Group

Exercise 3 – When to Avoid 3D

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did