{"spec_id":"contour-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# contour-basic: Basic Contour Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 89/100 | Created: 2026-06-25\n\nusing CairoMakie\nusing Colors\nusing ColorSchemes\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\"\n\n# Imprint diverging colormap: warm anomaly (red) ↔ near-neutral ↔ cool anomaly (blue)\nconst _midpoint   = THEME == \"light\" ? colorant\"#FAF8F1\" : colorant\"#1A1A17\"\nconst ANYPLOT_DIV = cgrad([colorant\"#AE3030\", _midpoint, colorant\"#4467A3\"])\n\n# Data — surface temperature anomaly field (°C relative to 30-year climatology mean)\nconst xs = LinRange(-5.0, 5.0, 80)\nconst ys = LinRange(-5.0, 5.0, 80)\nconst z = [\n    2.0 * exp(-0.5 * ((xi - 2.0)^2 + (yi - 1.5)^2)) -\n    2.0 * exp(-0.5 * ((xi + 2.0)^2 + (yi + 1.5)^2)) +\n    0.5 * sin(xi) * cos(yi)\n    for xi in xs, yi in ys\n]\n\nconst LEVELS = collect(range(-2.5, 2.5, step = 0.5))\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              = \"contour-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Longitude (°E)\",\n    ylabel             = \"Latitude (°N)\",\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    xticklabelsize     = 12,\n    yticklabelsize     = 12,\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    xgridvisible       = false,\n    ygridvisible       = false,\n)\n\n# Filled contours\ncf = contourf!(ax, xs, ys, z;\n    levels   = LEVELS,\n    colormap = ANYPLOT_DIV,\n)\n\n# Contour lines overlay\ncontour!(ax, xs, ys, z;\n    levels    = LEVELS,\n    color     = RGBAf(INK.r, INK.g, INK.b, 0.35f0),\n    linewidth = 0.8,\n)\n\n# Colorbar\nColorbar(fig[1, 2], cf;\n    label          = \"Temperature Anomaly (°C)\",\n    labelcolor     = INK,\n    labelsize      = 14,\n    tickcolor      = INK_SOFT,\n    ticklabelcolor = INK_SOFT,\n    ticklabelsize  = 12,\n    ticks          = -2.5:0.5:2.5,\n    width          = 20,\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}