{"spec_id":"scatter-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# scatter-basic: Basic Scatter Plot\n# Library: makie 0.21.9 | Julia 1.11.9\n# Quality: 88/100 | Created: 2026-06-25\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 BRAND    = colorant\"#009E73\"\n\n# Data — adult height (cm) vs weight (kg), simulated health study, n=150\nn = 150\nheight_cm = 170.0 .+ 10.0 .* randn(n)\nweight_kg = 0.5 .* height_cm .+ 5.0 .* randn(n) .- 15.0\n\n# Regression line\nx_bar     = mean(height_cm)\ny_bar     = mean(weight_kg)\nslope     = sum((height_cm .- x_bar) .* (weight_kg .- y_bar)) / sum((height_cm .- x_bar) .^ 2)\nintercept = y_bar - slope * x_bar\nx_fit     = LinRange(minimum(height_cm) - 1, maximum(height_cm) + 1, 200)\ny_fit     = slope .* x_fit .+ intercept\nr_val     = cor(height_cm, weight_kg)\n\n# Figure\nfig = Figure(\n    size            = (1600, 900),\n    fontsize        = 14,\n    backgroundcolor = PAGE_BG,\n)\n\n# Subtitle using Makie compositional layout slot above the main axis\nLabel(\n    fig[0, 1],\n    \"Pearson r = $(round(r_val; digits=2)) — positive correlation (height predicts weight, n=$n)\",\n    fontsize  = 13,\n    color     = INK_SOFT,\n    halign    = :left,\n    tellwidth = false,\n)\n\nax = Axis(\n    fig[1, 1];\n    title              = \"scatter-basic · julia · makie · anyplot.ai\",\n    titlesize          = 23,\n    titlecolor         = INK,\n    xlabel             = \"Height (cm)\",\n    ylabel             = \"Weight (kg)\",\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    xticksvisible      = false,\n    yticksvisible      = false,\n    backgroundcolor    = PAGE_BG,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinecolor     = INK_SOFT,\n    bottomspinecolor   = INK_SOFT,\n    xgridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.15),\n)\n\nscatter!(\n    ax, height_cm, weight_kg;\n    color       = (BRAND, 0.7),\n    markersize  = 12,\n    strokewidth = 1,\n    strokecolor = PAGE_BG,\n)\n\nlines!(ax, collect(x_fit), collect(y_fit); color = INK_SOFT, linewidth = 2.0, linestyle = :dash)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}