3D Scatter Plot — Makie.jl

A three-dimensional scatter plot that displays the relationship between three numeric variables by plotting points in 3D space. This visualization extends the classic 2D scatter plot to reveal patterns, clusters, and correlations across three dimensions simultaneously, making it invaluable for multivariate data exploration.

3D Scatter Plot rendered with Makie.jl

Renders

Julia source (Makie.jl)

# anyplot.ai
# scatter-3d: 3D Scatter Plot
# Library: makie 0.21.9 | Julia 1.11.9
# Quality: 87/100 | Created: 2026-09-10

using CairoMakie
using Colors
using Random

Random.seed!(42)

# --- Theme tokens ------------------------------------------------------------
const THEME       = get(ENV, "ANYPLOT_THEME", "light")
const PAGE_BG     = THEME == "light" ? colorant"#FAF8F1" : colorant"#1A1A17"
const ELEVATED_BG = THEME == "light" ? colorant"#FFFDF6" : colorant"#242420"
const INK         = THEME == "light" ? colorant"#1A1A17" : colorant"#F0EFE8"
const INK_SOFT    = THEME == "light" ? colorant"#4A4A44" : colorant"#B8B7B0"
const GRID        = RGBAf(INK.r, INK.g, INK.b, 0.15)

const IMPRINT_PALETTE = [
    colorant"#009E73", colorant"#C475FD", colorant"#4467A3", colorant"#BD8233",
    colorant"#AE3030", colorant"#2ABCCD", colorant"#954477", colorant"#99B314",
]

# --- Data ----------------------------------------------------------------------
# Sensor readings from a machine feature space (vibration, temperature,
# pressure), forming three clusters by operating mode. Idle and Normal
# deliberately overlap in vibration/temperature (the third axis, pressure,
# is what actually separates them) so the 3D view carries information a
# single 2D projection would not.
n_per_mode = 60
modes = ["Idle", "Normal", "Stress"]
centers = [(1.0, 55.0, 1.2), (1.5, 58.0, 3.0), (6.5, 92.0, 4.6)]
spreads = [(0.4, 3.5, 0.2), (0.45, 3.5, 0.3), (0.7, 5.0, 0.4)]

vibration = Float64[]
temperature = Float64[]
pressure = Float64[]
mode_idx = Int[]

for (i, (cx, cy, cz)) in enumerate(centers)
    sx, sy, sz = spreads[i]
    append!(vibration, cx .+ sx .* randn(n_per_mode))
    append!(temperature, cy .+ sy .* randn(n_per_mode))
    append!(pressure, cz .+ sz .* randn(n_per_mode))
    append!(mode_idx, fill(i, n_per_mode))
end

# --- Plot ------------------------------------------------------------------
fig = Figure(
    resolution      = (1600, 900),
    fontsize        = 14,
    backgroundcolor = PAGE_BG,
)

ax = Axis3(
    fig[1, 1];
    title             = "scatter-3d · julia · makie · anyplot.ai",
    titlesize         = 20,
    titlecolor        = INK,
    xlabel            = "Vibration (mm/s)",
    ylabel            = "Temperature (°C)",
    zlabel            = "Pressure (bar)",
    xlabelsize        = 14,
    ylabelsize        = 14,
    zlabelsize        = 14,
    xlabelcolor       = INK,
    ylabelcolor       = INK,
    zlabelcolor       = INK,
    xticklabelsize    = 12,
    yticklabelsize    = 12,
    zticklabelsize    = 12,
    xticklabelcolor   = INK_SOFT,
    yticklabelcolor   = INK_SOFT,
    zticklabelcolor   = INK_SOFT,
    xtickcolor        = INK_SOFT,
    ytickcolor        = INK_SOFT,
    ztickcolor        = INK_SOFT,
    xspinecolor_1     = INK_SOFT, xspinecolor_2 = INK_SOFT, xspinecolor_3 = INK_SOFT,
    yspinecolor_1     = INK_SOFT, yspinecolor_2 = INK_SOFT, yspinecolor_3 = INK_SOFT,
    zspinecolor_1     = INK_SOFT, zspinecolor_2 = INK_SOFT, zspinecolor_3 = INK_SOFT,
    xgridcolor        = GRID,
    ygridcolor        = GRID,
    zgridcolor        = GRID,
    xypanelcolor      = ELEVATED_BG,
    xzpanelcolor      = ELEVATED_BG,
    yzpanelcolor      = ELEVATED_BG,
    backgroundcolor   = PAGE_BG,
    azimuth           = 1.275 * pi,
    elevation         = 0.15 * pi,
    aspect            = (1, 1, 1),
)

for (i, name) in enumerate(modes)
    sel = mode_idx .== i
    scatter!(
        ax, vibration[sel], temperature[sel], pressure[sel];
        color = (IMPRINT_PALETTE[i], 0.85), markersize = 14,
        strokewidth = 0.5, strokecolor = PAGE_BG, label = name,
    )
end

axislegend(
    ax; position = :lt, framevisible = false, labelcolor = INK,
    labelsize = 12, backgroundcolor = :transparent,
)

# --- Save --------------------------------------------------------------------
save("plot-$(THEME).png", fig; px_per_unit = 2)

Retrieve this implementation

Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/scatter-3d/makie/code. Any spec id and library id listed in llms-full.txt fit the same URL shape; every URL below is complete and callable.

{
  "spec_id": "scatter-3d",
  "language": "julia",
  "library": "makie",
  "page": "https://anyplot.ai/scatter-3d/julia/makie",
  "hub": "https://anyplot.ai/scatter-3d",
  "code_json": "https://api.anyplot.ai/specs/scatter-3d/makie/code",
  "spec_json": "https://api.anyplot.ai/specs/scatter-3d",
  "render_light_png": "https://storage.googleapis.com/anyplot-images/plots/scatter-3d/julia/makie/plot-light.png",
  "render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/scatter-3d/julia/makie/plot-dark.png",
  "quality_score": 87.0,
  "license": "MIT",
  "guide": "https://anyplot.ai/llms.txt"
}

Part of 3D Scatter Plot on anyplot.ai.

Other implementations