{"spec_id":"errorbar-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# errorbar-basic: Basic Error Bar Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 88/100 | Created: 2026-06-30\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 INK_MUTED = THEME == \"light\" ? colorant\"#6B6A63\" : colorant\"#A8A79F\"\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\",  # 1 — first categorical series (Imprint brand green)\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]\n\n# Data: Mean seedling height (cm) under 6 light intensity levels\n# Standard deviation from 20 replicate seedlings per condition\nlight_levels = [\"50 lux\", \"100 lux\", \"200 lux\", \"400 lux\", \"800 lux\", \"1600 lux\"]\nmean_height  = [1.2, 2.8, 4.5, 6.1, 7.3, 7.8]\nstd_height   = [0.35, 0.42, 0.51, 0.68, 0.72, 0.85]\nn = length(light_levels)\nx_pos = collect(1:n)\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              = \"errorbar-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Light Intensity\",\n    ylabel             = \"Mean Seedling Height (cm)\",\n    xlabelsize         = 14,\n    ylabelsize         = 14,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\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    yminorgridvisible  = false,\n    xticks             = (x_pos, light_levels),\n)\n\n# Highlight the growth saturation region (800–1600 lux = x positions 5–6)\nc = IMPRINT_PALETTE[1]\nvspan!(ax, [4.5], [6.5];\n    color = RGBAf(Float32(c.r), Float32(c.g), Float32(c.b), 0.08f0),\n)\n\nerrorbars!(ax, x_pos, mean_height, std_height;\n    color        = IMPRINT_PALETTE[1],\n    linewidth    = 2.5,\n    whiskerwidth = 12,\n)\n\nlines!(ax, x_pos, mean_height;\n    color     = IMPRINT_PALETTE[1],\n    linewidth = 2.0,\n)\n\nscatter!(ax, x_pos, mean_height;\n    color       = IMPRINT_PALETTE[1],\n    markersize  = 14,\n    strokewidth = 1.5,\n    strokecolor = PAGE_BG,\n)\n\n# Annotate the saturation plateau to guide the reader to the key insight\ntext!(ax, 5.5, 8.4;\n    text     = \"growth plateau\",\n    color    = INK_MUTED,\n    fontsize = 12,\n    align    = (:center, :bottom),\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}