{"spec_id":"contour-3d","library":"makie","language":"julia","code":"# anyplot.ai\n# contour-3d: 3D Contour Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 81/100 | Created: 2026-09-10\n\nusing CairoMakie\nusing Colors\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\"\n\n# Imprint sequential colormap — brand green to blue (default-style-guide.md\n# \"Continuous Data\"). Elevation above sea level is single-polarity, so the\n# diverging cmap is not appropriate here.\nconst IMPRINT_SEQ = cgrad([colorant\"#009E73\", colorant\"#4467A3\"])\n\n# --- Data ---------------------------------------------------------------\n# Synthetic mountain-range terrain survey: three peaks of different heights\n# plus a gentle ripple for surface texture. Deterministic, no RNG needed.\neasting = range(-5, 5, length=45)\nnorthing = range(-5, 5, length=45)\n\nelevation(e, n) =\n    100 +\n    1200 * exp(-((e - 1.5)^2) / 4 - ((n - 1.0)^2) / 3) +\n    900 * exp(-((e + 2.0)^2) / 3 - ((n + 1.5)^2) / 2.5) +\n    600 * exp(-((e - 0.5)^2) / 2 - ((n - 2.5)^2) / 2) +\n    35 * sin(e) * cos(n)\n\nz = [elevation(e, n) for e in easting, n in northing]\n\n# --- Plot -----------------------------------------------------------------\ntitle_str = \"contour-3d · julia · makie · anyplot.ai\"\n\nfig = Figure(\n    resolution      = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis3(\n    fig[1, 1];\n    title              = title_str,\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Easting (km)\",\n    ylabel             = \"Northing (km)\",\n    zlabel             = \"Elevation (m)\",\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    zlabelsize         = 14,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    zlabelcolor        = INK,\n    xticklabelsize     = 12,\n    yticklabelsize     = 12,\n    zticklabelsize     = 12,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    zticklabelcolor    = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    ztickcolor         = INK_SOFT,\n    xspinecolor_1      = INK_SOFT,\n    yspinecolor_1      = INK_SOFT,\n    zspinecolor_1      = INK_SOFT,\n    xspinecolor_2      = INK_SOFT,\n    yspinecolor_2      = INK_SOFT,\n    zspinecolor_2      = INK_SOFT,\n    xspinecolor_3      = INK_SOFT,\n    yspinecolor_3      = INK_SOFT,\n    zspinecolor_3      = 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    zgridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    xypanelcolor       = PAGE_BG,\n    xzpanelcolor       = PAGE_BG,\n    yzpanelcolor       = PAGE_BG,\n    backgroundcolor    = PAGE_BG,\n    aspect             = (1, 1, 0.55),\n    azimuth            = 1.28 * pi,\n    elevation          = 0.16 * pi,\n    protrusions        = (60, 60, 10, 60),\n)\n\n# Shaded surface preserving the terrain's 3D geometry\nsurf = surface!(ax, easting, northing, z; colormap = IMPRINT_SEQ, shading = NoShading)\n\n# Isolines traced directly on the surface at their true elevation. Fewer,\n# more widely spaced levels avoid two rings crowding into a near-solid disc\n# on the shorter secondary peak.\ncontour3d!(ax, easting, northing, z; levels = 6, color = INK, linewidth = 1.5)\n\nColorbar(\n    fig[1, 2], surf;\n    label = \"Elevation (m)\", width = 22,\n    labelcolor = INK, ticklabelcolor = INK_SOFT, tickcolor = INK_SOFT,\n    leftspinecolor = INK_SOFT, rightspinecolor = INK_SOFT,\n    topspinecolor = INK_SOFT, bottomspinecolor = INK_SOFT,\n)\n\ncolsize!(fig.layout, 1, Relative(0.88))\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}