{"spec_id":"lollipop-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# lollipop-basic: Basic Lollipop Chart\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 90/100 | Created: 2026-07-01\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_PALETTE = [\n    colorant\"#009E73\",  # 1 — brand green (always first categorical series)\n    colorant\"#C475FD\",  # 2 — lavender\n    colorant\"#4467A3\",  # 3 — blue\n    colorant\"#BD8233\",  # 4 — ochre\n    colorant\"#AE3030\",  # 5 — matte red\n    colorant\"#2ABCCD\",  # 6 — cyan\n    colorant\"#954477\",  # 7 — rose\n    colorant\"#99B314\",  # 8 — lime\n]\nconst ANYPLOT_AMBER = colorant\"#DDCC77\"\n\n# Data — renewable energy share (%) by country\ncountries = [\"Norway\", \"Iceland\", \"Austria\", \"Sweden\", \"New Zealand\",\n             \"Germany\", \"UK\", \"Canada\", \"Australia\", \"USA\"]\npct_renew = [98.0, 85.0, 71.0, 65.0, 58.0, 46.0, 39.0, 32.0, 24.0, 18.0]\n\n# Sort ascending so values rise left-to-right\norder            = sortperm(pct_renew)\nsorted_countries = countries[order]\nsorted_pct       = pct_renew[order]\nn                = length(sorted_pct)\n\n# Amber accent on the clear leader (Norway 98%, rightmost after ascending sort)\nbase_color  = IMPRINT_PALETTE[1]\ndot_colors  = [i == n ? ANYPLOT_AMBER : base_color for i in 1:n]\nstem_colors = [c for dc in dot_colors for c in (dc, dc)]  # 2 points per stem\n\n# Build stem point pairs for linesegments!\nstem_pts = Point2f[]\nfor (i, val) in enumerate(sorted_pct)\n    push!(stem_pts, Point2f(i, 0.0))\n    push!(stem_pts, Point2f(i, val))\nend\n\n# Figure\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"lollipop-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Country\",\n    ylabel             = \"Renewable Energy Share (%)\",\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    backgroundcolor    = PAGE_BG,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    xgridvisible       = false,\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    yminorgridvisible  = false,\n    xminorgridvisible  = false,\n)\n\nax.xticks = (1:n, sorted_countries)\nax.xticklabelrotation = π / 6\n\n# 50% reference line — \"majority renewable\" threshold\nhlines!(ax, [50.0]; color = RGBAf(INK.r, INK.g, INK.b, 0.35), linestyle = :dash, linewidth = 1.5)\ntext!(ax, 1.1, 52.0; text = \"50% threshold\", color = INK_SOFT, fontsize = 10, align = (:left, :bottom))\n\n# Stems\nlinesegments!(ax, stem_pts; color = stem_colors, linewidth = 2.5)\n\n# Dots\nscatter!(ax, collect(1:n), sorted_pct;\n    color       = dot_colors,\n    markersize  = 18,\n    strokewidth = 2.0,\n    strokecolor = PAGE_BG,\n)\n\n# Value annotations via Makie's native text! — lightweight data labels\nfor (i, val) in enumerate(sorted_pct)\n    text!(ax, i, val + 3.0;\n        text     = \"$(Int(val))%\",\n        color    = INK_SOFT,\n        fontsize = 10,\n        align    = (:center, :bottom),\n    )\nend\n\nylims!(ax, 0, 115)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}