{"spec_id":"histogram-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# histogram-basic: Basic Histogram\n# Library: makie 0.24.16 | Julia 1.13.4\n# Quality: 84/100 | Updated: 2026-11-26\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\"\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 CUSTOMER_AGE = \"Customer age (years)\"  # role: value\n\n# Data: replace this block with your own table, for example df = CSV.read(\"customers.csv\", DataFrame)\nRandom.seed!(42)\nages_young = randn(200) .* 5 .+ 28\nages_mid = randn(150) .* 8 .+ 55\ndf = DataFrame(CUSTOMER_AGE => clamp.(vcat(ages_young, ages_mid), 18, 75))\n\n# Plot: reads only df and the constants above\nfig = Figure(\n    size = (1600, 900),\n    fontsize = 14,\n    backgroundcolor = PAGE_BG,\n)\n\nax = Axis(\n    fig[1, 1];\n    title = \"histogram-basic · julia · makie · anyplot.ai\",\n    titlesize = 24,\n    titlecolor = INK,\n    xlabel = CUSTOMER_AGE,\n    ylabel = \"Count\",\n    xlabelsize = 20,\n    ylabelsize = 20,\n    xlabelcolor = INK,\n    ylabelcolor = INK,\n    xticklabelsize = 17,\n    yticklabelsize = 17,\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(INK.r, INK.g, INK.b, 0.15f0),\n    xminorgridvisible = false,\n    yminorgridvisible = false,\n    limits = (nothing, nothing, 0, nothing),\n)\n\nhist!(ax, df[!, CUSTOMER_AGE];\n    bins = 28,\n    color = IMPRINT_PALETTE[1],\n    strokecolor = PAGE_BG,\n    strokewidth = 1.5,\n)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}