A scatter plot that encodes a third continuous variable using a colormap, allowing visualization of three dimensions on a 2D plane. This visualization is essential for exploring multivariate relationships where the third variable represents intensity, magnitude, or any continuous measurement. A colorbar provides a reference scale for interpreting the color values.

# anyplot.ai
# scatter-color-mapped: Color-Mapped Scatter Plot
# Library: makie 0.21.9 | Julia 1.11.9
# Quality: 92/100 | Created: 2026-09-05
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 INK = THEME == "light" ? colorant"#1A1A17" : colorant"#F0EFE8"
const INK_SOFT = THEME == "light" ? colorant"#4A4A44" : colorant"#B8B7B0"
const IMPRINT_SEQ = cgrad([colorant"#009E73", colorant"#4467A3"])
# --- Data ---------------------------------------------------------------
n = 250
easting = rand(n) .* 120 # meters east of survey origin
northing = rand(n) .* 80 # meters north of survey origin
trend(e, no) = 40.0 + 25.0 * (e / 120) + 10.0 * sin(no / 12) # deterministic spatial gradient
concentration = trend.(easting, northing) .+ 15.0 .* randn(n)
concentration = clamp.(concentration, 5.0, 100.0)
color_range = (5.0, 100.0)
# Smooth backdrop of the underlying spatial trend (noise-free) so the
# eastward concentration gradient reads at a glance, not only via the colorbar.
trend_xs = range(0.0, 120.0; length = 60)
trend_ys = range(0.0, 80.0; length = 40)
trend_zs = [trend(e, no) for e in trend_xs, no in trend_ys]
# --- Plot -----------------------------------------------------------------
fig = Figure(
size = (1600, 900),
fontsize = 14,
backgroundcolor = PAGE_BG,
)
ax = Axis(
fig[1, 1];
title = "scatter-color-mapped · julia · makie · anyplot.ai",
titlesize = 20,
titlecolor = INK,
xlabel = "Easting (m)",
ylabel = "Northing (m)",
xlabelsize = 14,
ylabelsize = 14,
xlabelcolor = INK,
ylabelcolor = INK,
xticklabelsize = 12,
yticklabelsize = 12,
xticklabelcolor = INK_SOFT,
yticklabelcolor = INK_SOFT,
xtickcolor = INK_SOFT,
ytickcolor = INK_SOFT,
backgroundcolor = PAGE_BG,
topspinevisible = false,
rightspinevisible = false,
leftspinecolor = INK_SOFT,
bottomspinecolor = INK_SOFT,
xgridcolor = RGBAf(INK.r, INK.g, INK.b, 0.15),
ygridcolor = RGBAf(INK.r, INK.g, INK.b, 0.15),
)
heatmap!(
ax, trend_xs, trend_ys, trend_zs;
colormap = IMPRINT_SEQ,
colorrange = extrema(trend_zs),
alpha = 0.18,
)
sc = scatter!(
ax, easting, northing;
color = concentration,
colormap = IMPRINT_SEQ,
colorrange = color_range,
markersize = 16,
alpha = 0.85,
strokewidth = 0.75,
strokecolor = PAGE_BG,
)
Colorbar(
fig[1, 2], sc;
label = "Mineral Concentration (ppm)",
labelsize = 14,
labelcolor = INK,
ticklabelsize = 12,
ticklabelcolor = INK_SOFT,
tickcolor = INK_SOFT,
)
# --- Save -------------------------------------------------------------------
save("plot-$(THEME).png", fig; px_per_unit = 2)
Runnable source as JSON, for any HTTP client: https://api.anyplot.ai/specs/scatter-color-mapped/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-color-mapped",
"language": "julia",
"library": "makie",
"page": "https://anyplot.ai/scatter-color-mapped/julia/makie",
"hub": "https://anyplot.ai/scatter-color-mapped",
"code_json": "https://api.anyplot.ai/specs/scatter-color-mapped/makie/code",
"spec_json": "https://api.anyplot.ai/specs/scatter-color-mapped",
"render_light_png": "https://storage.googleapis.com/anyplot-images/plots/scatter-color-mapped/julia/makie/plot-light.png",
"render_dark_png": "https://storage.googleapis.com/anyplot-images/plots/scatter-color-mapped/julia/makie/plot-dark.png",
"quality_score": 92.0,
"license": "MIT",
"guide": "https://anyplot.ai/llms.txt"
}Part of Color-Mapped Scatter Plot on anyplot.ai.