{"spec_id":"stem-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# stem-basic: Basic Stem Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 87/100 | Created: 2026-07-25\n\nusing CairoMakie\nusing Colors\n\n# Theme tokens (see prompts/default-style-guide.md \"Background\" + \"Theme-adaptive Chrome\")\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 BRAND    = colorant\"#009E73\"  # Imprint palette position 1 — ALWAYS first series\n\n# Data — impulse response of a damped second-order system (classic DSP stem example)\n# Faster decay + a trimmed sample count keep every stem visually meaningful\n# (no long near-zero tail eating half the canvas)\nn = 0:29\ndecay = exp.(-0.18 .* n)\namplitude = decay .* sin.(0.8 .* n)\npeak_idx = argmax(abs.(amplitude))\n\n# Plot\nfig = Figure(\n    resolution      = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"stem-basic · julia · makie · anyplot.ai\",\n    titlesize          = 22,\n    titlefont          = :bold,\n    titlecolor         = INK,\n    xlabel             = \"Sample Index (n)\",\n    ylabel             = \"Amplitude\",\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    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.12),\n    xgridvisible       = false,\n)\n\n# Decay envelope — theme-neutral reference curves (Imprint \"neutral\" anchor) that make\n# the damped-oscillation shape explicit and give the plot a deliberate focal structure\nlines!(ax, n, decay; color = RGBAf(INK.r, INK.g, INK.b, 0.35), linewidth = 1.5, linestyle = :dash)\nlines!(ax, n, -decay; color = RGBAf(INK.r, INK.g, INK.b, 0.35), linewidth = 1.5, linestyle = :dash)\n\nstem!(ax, n, amplitude;\n    color       = BRAND,\n    stemcolor   = BRAND,\n    stemwidth   = 2.5,\n    marker      = :circle,\n    markersize  = 16,\n    strokewidth = 1.5,\n    strokecolor = PAGE_BG,\n    trunkcolor  = INK_SOFT,\n    trunkwidth  = 1.5,\n)\n\n# Halo + label on the largest-magnitude stem — a clear, intentional focal point\nscatter!(ax, [n[peak_idx]], [amplitude[peak_idx]];\n    color       = (BRAND, 0.25),\n    markersize  = 34,\n    strokewidth = 0,\n)\ntext!(ax, n[peak_idx], amplitude[peak_idx];\n    text     = \"peak: $(round(amplitude[peak_idx]; digits = 2))\",\n    align    = (:left, :bottom),\n    offset   = (10, 10),\n    fontsize = 13,\n    color    = INK_SOFT,\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}