{"spec_id":"arc-basic","library":"makie","language":"julia","code":"# anyplot.ai\n# arc-basic: Basic Arc Diagram\n# Library: makie 0.22.10 | Julia 1.11.9\n# Quality: 87/100 | Created: 2026-05-30\n\nusing CairoMakie\nusing Colors\n\n# Theme tokens — Imprint palette\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\nconst BRAND  = colorant\"#009E73\"  # Imprint position 1 — within-group edges\nconst ACCENT = colorant\"#C475FD\"  # Imprint position 2 — cross-group edges\n\n# Data — research collaboration network (12 researchers, 17 co-authorship links)\nconst node_names = [\n    \"Alice\", \"Bob\", \"Carol\", \"Dave\",\n    \"Eve\", \"Frank\", \"Grace\", \"Hank\",\n    \"Iris\", \"Jack\", \"Kim\", \"Leo\",\n]\nconst n_nodes = length(node_names)\n\n# Groups: A = 1–4, B = 5–8, C = 9–12\n# (src, tgt, weight, cross_group)\nconst edges = [\n    (1, 2, 5, false), (1, 3, 4, false), (2, 4, 3, false), (3, 4, 4, false),\n    (5, 6, 4, false), (5, 7, 5, false), (6, 8, 3, false), (7, 8, 4, false),\n    (9, 10, 5, false), (9, 11, 3, false), (10, 12, 4, false), (11, 12, 3, false),\n    (2, 5, 2, true), (4, 7, 2, true), (8, 9, 1, true), (3, 11, 1, true), (1, 12, 1, true),\n]\n\nconst node_x     = Float64.(0:(n_nodes - 1))\nconst max_weight = maximum(w for (_, _, w, _) in edges)\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    backgroundcolor    = PAGE_BG,\n    title              = \"arc-basic · julia · makie · anyplot.ai\",\n    titlesize          = 20,\n    titlecolor         = INK,\n    topspinevisible    = false,\n    rightspinevisible  = false,\n    leftspinevisible   = false,\n    bottomspinevisible = false,\n    xgridvisible       = false,\n    ygridvisible       = false,\n    xticksvisible      = false,\n    yticksvisible      = false,\n    xticklabelsvisible = false,\n    yticklabelsvisible = false,\n)\n\n# Arcs — color-coded by edge type; weight encodes opacity and linewidth\nfor (src, tgt, weight, is_cross) in edges\n    xi, xj = node_x[src], node_x[tgt]\n    cx = (xi + xj) / 2.0\n    r  = abs(xj - xi) / 2.0\n    h  = r * 0.55\n\n    t     = range(0.0, π; length = 300)\n    arc_x = cx .+ r .* cos.(t)\n    arc_y = h .* sin.(t)\n\n    alpha = 0.3 + 0.5 * (weight / max_weight)\n    lw    = 1.0 + 2.5 * (weight / max_weight)\n    col   = is_cross ? ACCENT : BRAND\n\n    lines!(ax, arc_x, arc_y; color = (col, alpha), linewidth = lw)\nend\n\n# Horizontal baseline\nlines!(ax, [node_x[1] - 0.5, node_x[end] + 0.5], [0.0, 0.0];\n       color = INK_SOFT, linewidth = 1.5)\n\n# Node dots\nscatter!(ax, node_x, zeros(n_nodes);\n         color       = BRAND,\n         markersize  = 16,\n         strokewidth = 1.5,\n         strokecolor = PAGE_BG)\n\n# Node labels\nfor (i, name) in enumerate(node_names)\n    text!(ax, node_x[i], -0.12;\n          text     = name,\n          fontsize = Float32(13),\n          color    = INK_SOFT,\n          align    = (:center, :top))\nend\n\nylims!(ax, -0.65, 3.8)\nxlims!(ax, -0.8, 12.0)\n\n# Makie Legend with LineElement + MarkerElement — Makie-idiomatic typed legend entries\nleg_elements = [\n    [LineElement(color = (BRAND, 0.8), linewidth = 3.5)],\n    [LineElement(color = (ACCENT, 0.8), linewidth = 2.0)],\n    [MarkerElement(color = BRAND, marker = :circle, markersize = 14,\n                   strokewidth = 1.5, strokecolor = PAGE_BG)],\n]\nleg_labels = [\"Within-group (weight 3–5)\", \"Cross-group (weight 1–2)\", \"Researcher\"]\n\nLegend(\n    fig[1, 2],\n    leg_elements,\n    leg_labels;\n    title           = \"Connection type\",\n    titlesize       = 13,\n    labelsize       = 12,\n    titlecolor      = INK,\n    labelcolor      = INK_SOFT,\n    framevisible    = false,\n    backgroundcolor = PAGE_BG,\n    tellheight      = false,\n    patchsize       = (24, 10),\n    padding         = (8, 8, 8, 8),\n    rowgap          = 6,\n)\n\ncolsize!(fig.layout, 1, Relative(0.80))\n\nsave(\"plot-$(THEME).png\", fig; px_per_unit = 2)\n"}