{"spec_id":"hexbin-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# hexbin-basic: Basic Hexbin Plot\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 85/100 | Created: 2026-05-29\n\nusing CairoMakie\nusing Colors\nusing ColorSchemes\nusing Random\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 ELEVATED_BG = THEME == \"light\" ? colorant\"#FFFDF6\" : colorant\"#242420\"\nconst INK         = THEME == \"light\" ? colorant\"#1A1A17\" : colorant\"#F0EFE8\"\nconst INK_SOFT    = THEME == \"light\" ? colorant\"#4A4A44\" : colorant\"#B8B7B0\"\n\n# Imprint sequential colormap: brand green → blue (single-polarity density)\nconst ANYPLOT_SEQ = cgrad([colorant\"#009E73\", colorant\"#4467A3\"])\n\n# Data: simulated urban GPS coordinates with clustered hotspots (12000 points)\n# City center — highest density\nn1 = 5000\nx1 = randn(n1) .* 0.4 .+ 0.0\ny1 = randn(n1) .* 0.4 .+ 0.0\n\n# Northern district\nn2 = 2500\nx2 = randn(n2) .* 0.5 .+ -2.0\ny2 = randn(n2) .* 0.4 .+ 2.2\n\n# Eastern commercial zone\nn3 = 2500\nx3 = randn(n3) .* 0.5 .+ 2.4\ny3 = randn(n3) .* 0.4 .+ 0.6\n\n# Southern transit hub\nn4 = 2000\nx4 = randn(n4) .* 0.45 .+ 0.4\ny4 = randn(n4) .* 0.40 .+ -2.5\n\nx_coords = vcat(x1, x2, x3, x4)\ny_coords = vcat(y1, y2, y3, y4)\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              = \"hexbin-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    xlabel             = \"Longitude (relative km)\",\n    ylabel             = \"Latitude (relative km)\",\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    xgridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.12f0),\n    ygridcolor         = RGBAf(INK.r, INK.g, INK.b, 0.12f0),\n    xminorgridvisible  = false,\n    yminorgridvisible  = false,\n)\n\n# Log colorscale surfaces peripheral mid-density clusters that would otherwise wash out\nhb = hexbin!(ax, x_coords, y_coords;\n    bins        = 50,\n    colormap    = ANYPLOT_SEQ,\n    colorscale  = log10,\n    strokewidth = 0,\n)\n\n# Colorbar with log-scale ticks at interpretable landmark counts\nColorbar(fig[1, 2], hb;\n    label          = \"Point Count\",\n    labelsize      = 14,\n    labelcolor     = INK,\n    ticklabelsize  = 11,\n    ticklabelcolor = INK_SOFT,\n    tickcolor      = INK_SOFT,\n    ticks          = ([1, 5, 20, 80, 250], [\"1\", \"5\", \"20\", \"80\", \"250\"]),\n    width          = 22,\n)\n\n# Focal annotation: ring + label calling out the city center peak-density cluster\nscatter!(ax, [0.0], [0.0];\n    marker      = :circle,\n    markersize  = 42,\n    color       = :transparent,\n    strokewidth = 2.2,\n    strokecolor = INK,\n)\ntext!(ax, 0.5, 0.1;\n    text     = \"City Center\\n(peak density)\",\n    color    = INK,\n    fontsize = 11,\n    align    = (:left, :center),\n)\n\ncolsize!(fig.layout, 1, Relative(0.87))\ncolgap!(fig.layout, 14)\n\n# Save\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}