{"spec_id":"scatter-color-mapped","library":"makie","language":"julia","code":"# anyplot.ai\n# scatter-color-mapped: Color-Mapped Scatter Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 92/100 | Created: 2026-09-05\n\nusing CairoMakie\nusing Colors\nusing Random\n\nRandom.seed!(42)\n\n# --- Theme tokens -----------------------------------------------------------\nconst THEME       = get(ENV, \"ANYPLOT_THEME\", \"light\")\nconst PAGE_BG     = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst INK         = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst INK_SOFT    = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\nconst IMPRINT_SEQ = cgrad([colorant\"#009E73\", colorant\"#4467A3\"])\n\n# --- Data ---------------------------------------------------------------\nn = 250\neasting = rand(n) .* 120                                             # meters east of survey origin\nnorthing = rand(n) .* 80                                              # meters north of survey origin\ntrend(e, no) = 40.0 + 25.0 * (e / 120) + 10.0 * sin(no / 12)          # deterministic spatial gradient\nconcentration = trend.(easting, northing) .+ 15.0 .* randn(n)\nconcentration = clamp.(concentration, 5.0, 100.0)\ncolor_range = (5.0, 100.0)\n\n# Smooth backdrop of the underlying spatial trend (noise-free) so the\n# eastward concentration gradient reads at a glance, not only via the colorbar.\ntrend_xs = range(0.0, 120.0; length = 60)\ntrend_ys = range(0.0, 80.0; length = 40)\ntrend_zs = [trend(e, no) for e in trend_xs, no in trend_ys]\n\n# --- Plot -----------------------------------------------------------------\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title             = \"scatter-color-mapped · julia · makie · anyplot.ai\",\n    titlesize         = 20,\n    titlecolor        = INK,\n    xlabel            = \"Easting (m)\",\n    ylabel            = \"Northing (m)\",\n    xlabelsize        = 14,\n    ylabelsize        = 14,\n    xlabelcolor       = INK,\n    ylabelcolor       = INK,\n    xticklabelsize    = 12,\n    yticklabelsize    = 12,\n    xticklabelcolor   = INK_SOFT,\n    yticklabelcolor   = INK_SOFT,\n    xtickcolor        = INK_SOFT,\n    ytickcolor        = INK_SOFT,\n    backgroundcolor   = PAGE_BG,\n    topspinevisible   = false,\n    rightspinevisible = false,\n    leftspinecolor    = INK_SOFT,\n    bottomspinecolor  = INK_SOFT,\n    xgridcolor        = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    ygridcolor        = RGBAf(INK.r, INK.g, INK.b, 0.15),\n)\n\nheatmap!(\n    ax, trend_xs, trend_ys, trend_zs;\n    colormap   = IMPRINT_SEQ,\n    colorrange = extrema(trend_zs),\n    alpha      = 0.18,\n)\n\nsc = scatter!(\n    ax, easting, northing;\n    color       = concentration,\n    colormap    = IMPRINT_SEQ,\n    colorrange  = color_range,\n    markersize  = 16,\n    alpha       = 0.85,\n    strokewidth = 0.75,\n    strokecolor = PAGE_BG,\n)\n\nColorbar(\n    fig[1, 2], sc;\n    label          = \"Mineral Concentration (ppm)\",\n    labelsize      = 14,\n    labelcolor     = INK,\n    ticklabelsize  = 12,\n    ticklabelcolor = INK_SOFT,\n    tickcolor      = INK_SOFT,\n)\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}