{"spec_id":"box-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# box-basic: Basic Box Plot\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 83/100 | Created: 2026-05-28\n\nusing CairoMakie\nusing Colors\nusing Random\nusing Statistics\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\",\n    colorant\"#C475FD\",\n    colorant\"#4467A3\",\n    colorant\"#BD8233\",\n    colorant\"#AE3030\",\n]\n\n# Data: annual salaries (K USD) across 5 company departments\ndept_names = [\"Engineering\", \"Marketing\", \"Finance\", \"Sales\", \"Operations\"]\nn_per_dept = [120, 80, 90, 100, 110]\ndept_means = [95.0, 72.0, 88.0, 68.0, 62.0]\ndept_stds  = [18.0, 14.0, 16.0, 15.0, 10.0]\n\ngroups   = Int[]\nsalaries = Float64[]\nfor i in 1:5\n    append!(groups, fill(i, n_per_dept[i]))\n    raw = randn(n_per_dept[i]) .* dept_stds[i] .+ dept_means[i]\n    append!(salaries, max.(raw, 30.0))\nend\n\nall_median = median(salaries)\n\n# Engineering (group 1) at full opacity; others dimmed to highlight highest-paid dept\nbox_colors = [\n    RGBAf(red(IMPRINT_PALETTE[g]), green(IMPRINT_PALETTE[g]), blue(IMPRINT_PALETTE[g]),\n          g == 1 ? 1.0 : 0.5)\n    for g in groups\n]\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              = \"box-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Department\",\n    ylabel             = \"Annual Salary (K USD)\",\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    xgridvisible       = false,\n    ygridcolor         = RGBAf(red(INK), green(INK), blue(INK), 0.15),\n    yminorgridvisible  = false,\n    xminorgridvisible  = false,\n)\n\nboxplot!(ax, groups, salaries;\n    color            = box_colors,\n    strokecolor      = INK_SOFT,\n    strokewidth      = 1.5,\n    mediancolor      = INK,\n    whiskerlinewidth = 2.0,\n    width            = 0.65,\n    markersize       = 8,\n)\n\nax.xticks = (1:5, dept_names)\n\n# Tighten y-axis to remove dead canvas space at bottom\nylims!(ax, 28, nothing)\n\n# Dashed reference line at cross-department median\nhlines!(ax, [all_median]; color = INK_SOFT, linestyle = :dash, linewidth = 1.5)\ntext!(ax, 0.58, all_median;\n    text  = \"all-dept median: $(round(Int, all_median))K\",\n    color = INK_SOFT,\n    fontsize = 10,\n    align = (:left, :bottom),\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}