{"spec_id":"box-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# box-basic: Basic Box Plot\n# Library: makie 0.24.16 | Julia 1.13.4\n# Quality: 82/100 | Updated: 2026-11-27\n\nusing CairoMakie\nusing Colors\nusing DataFrames\nusing Random\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 palette\nconst IMPRINT_PALETTE = [\n    colorant\"#009E73\", colorant\"#C475FD\", colorant\"#4467A3\", colorant\"#BD8233\",\n    colorant\"#AE3030\", colorant\"#2ABCCD\", colorant\"#954477\", colorant\"#99B314\",\n]\n\n# Columns: set these to your table's column names\nconst DEPARTMENT = \"Department\"            # role: category\nconst SALARY = \"Annual Salary (K USD)\"     # role: value\n\n# Data: replace this block with your own table, for example df = CSV.read(\"salaries.csv\", DataFrame)\nRandom.seed!(42)\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]\ndf = DataFrame(\n    DEPARTMENT => reduce(vcat, [fill(dept_names[i], n_per_dept[i]) for i in 1:5]),\n    SALARY => reduce(vcat, [max.(randn(n_per_dept[i]) .* dept_stds[i] .+ dept_means[i], 30.0) for i in 1:5]),\n)\n\n# Plot: reads only df and the constants above\ndepartments = unique(df[!, DEPARTMENT])\ngroup = [findfirst(==(d), departments) for d in df[!, DEPARTMENT]]\n\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             = SALARY,\n    xlabelsize         = 16,\n    ylabelsize         = 16,\n    xlabelcolor        = INK,\n    ylabelcolor        = INK,\n    xticklabelsize     = 14,\n    yticklabelsize     = 14,\n    xticklabelcolor    = INK_SOFT,\n    yticklabelcolor    = INK_SOFT,\n    xtickcolor         = INK_SOFT,\n    ytickcolor         = INK_SOFT,\n    xticks             = (1:length(departments), departments),\n    backgroundcolor    = PAGE_BG,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    xgridvisible       = false,\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    yminorgridvisible  = false,\n    xminorgridvisible  = false,\n)\n\nboxplot!(ax, group, df[!, SALARY];\n    color            = IMPRINT_PALETTE[group],\n    strokecolor      = INK_SOFT,\n    strokewidth      = 1.5,\n    mediancolor      = INK,\n    medianlinewidth  = 3,\n    whiskercolor     = INK_SOFT,\n    whiskerlinewidth = 2.0,\n    width            = 0.65,\n    markersize       = 9,\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}