{"spec_id":"bar-diverging","library":"makie","language":"julia","code":"# anyplot.ai\n# bar-diverging: Diverging Bar Chart\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 91/100 | Created: 2026-08-18\n\nusing CairoMakie\nusing Colors\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 — semantic exception: positive/negative sentiment maps to\n# brand green (position 1) and matte red (position 5, the bad/loss anchor).\nconst POSITIVE = colorant\"#009E73\"\nconst NEGATIVE = colorant\"#AE3030\"\n\n# --- Data ---------------------------------------------------------------------\ncategories = [\n    \"Compensation\", \"Onboarding Process\", \"Recognition\", \"Workload Balance\",\n    \"Remote Flexibility\", \"Team Collaboration\", \"Management Support\",\n    \"Career Growth\", \"Learning Resources\", \"Company Culture\",\n]\nnet_agreement = [-42.0, -28.0, -15.0, -9.0, 6.0, 14.0, 21.0, 33.0, 38.0, 47.0]\n\norder = sortperm(net_agreement)\ncategories = categories[order]\nnet_agreement = net_agreement[order]\nbar_colors = [v >= 0 ? POSITIVE : NEGATIVE for v in net_agreement]\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              = \"Employee Engagement Survey · bar-diverging · julia · makie · anyplot.ai\",\n    titlesize          = 19,\n    titlecolor         = INK,\n    xlabel             = \"Net Agreement (percentage points)\",\n    xlabelsize         = 14,\n    xlabelcolor        = INK,\n    xticklabelsize     = 12,\n    yticklabelsize     = 13,\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    leftspinevisible   = false,\n    bottomspinecolor   = INK_SOFT,\n    xgridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    ygridvisible       = false,\n    yticks             = (1:length(categories), categories),\n    yticksvisible      = false,\n)\n\nbarplot!(\n    ax, 1:length(categories), net_agreement;\n    direction = :x, color = bar_colors, width = 0.65,\n)\nvlines!(ax, [0.0]; color = INK, linewidth = 1.5)\n\nspan = maximum(abs.(net_agreement)) * 1.25\nxlims!(ax, -span, span)\n\n# --- Save -------------------------------------------------------------------\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}