Skip to content

feat(seaborn): implement network-force-directed#5433

Merged
github-actions[bot] merged 5 commits intomainfrom
implementation/network-force-directed/seaborn
Apr 26, 2026
Merged

feat(seaborn): implement network-force-directed#5433
github-actions[bot] merged 5 commits intomainfrom
implementation/network-force-directed/seaborn

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: network-force-directed - python/seaborn

Implements the python/seaborn version of network-force-directed.

File: plots/network-force-directed/implementations/python/seaborn.py

Parent Issue: #990


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 26, 2026

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): Warm off-white background (#FAF8F1), not pure white. Title "Organizational Network · network-force-directed · seaborn · anyplot.ai" in dark text — clearly readable. Axis labels "Force-Directed X Position" and "Force-Directed Y Position" readable. Legend ("Department") upper-left shows Engineering (15), Marketing (12), Sales (10) with readable text. Three communities clearly distinguished by Okabe-Ito colors: Engineering teal/green (#009E73), Marketing orange/vermillion (#D55E00), Sales blue (#0072B2). Node sizes vary noticeably by degree (hubs larger). Edges in light gray with varying thickness by weight. Hub node labels (Node 3, Node 4, Node 21, Node 20, Node 28, Node 30) positioned above nodes, readable. Network stats annotation at bottom center readable. All text readable against light background — PASS.

Dark render (plot-dark.png): Warm near-black background (~#1A1A17), not pure black. Title, axis labels, and legend all rendered in light/off-white text — clearly readable against dark background. No dark-on-dark failures visible in the images. Data colors are identical to the light render (Engineering teal, Marketing orange, Sales blue) — only chrome flips, data colors stay constant. Edges appear slightly lighter on dark background. All community and node structure identical. All text readable against dark background — PASS (see weakness: source code has hardcoded color='#333333' for hub annotations and '#666666' for stats text, which would produce dark-on-dark failures if the code in seaborn.py actually generated these images; the images appear to be from a regenerated version with proper theme adaptation).

Both paragraphs are required. A review that only describes one render is invalid.

Score: 76/100

Category Score Max
Visual Quality 26 30
Design Excellence 8 20
Spec Compliance 14 15
Data Quality 15 15
Code Quality 9 10
Library Mastery 4 10
Total 76 100

Visual Quality (26/30)

  • VQ-01: Text Legibility (6/8) — Title 24pt, axis labels 20pt, legend 16pt all explicitly set. Hub annotation labels at fontsize=12 are below the 16pt minimum for secondary/tertiary text at 4800×2700px.
  • VQ-02: No Overlap (6/6) — Force-directed layout distributes nodes well; hub labels with y-offset, no collisions.
  • VQ-03: Element Visibility (5/6) — Node sizes scale by degree (150+degree×60), edge widths by weight (1+weight×2). Visibility good; size range somewhat subtle.
  • VQ-04: Color Accessibility (2/2) — Okabe-Ito is CVD-safe; communities distinguishable by both hue and size.
  • VQ-05: Layout & Canvas (3/4) — Network fills canvas well, balanced margins, legend and stats well-placed. Minor: axis labels on a network viz with no tick values add minimal value.
  • VQ-06: Axis Labels & Title (2/2) — Axis labels descriptive ("Force-Directed X/Y Position"), title present and readable.
  • VQ-07: Palette Compliance (2/2) — Images show Okabe-Ito colors (Engineering=#009E73, Marketing=#D55E00, Sales=#0072B2), correct warm backgrounds, theme-adaptive chrome. ⚠️ Source code uses wrong palette (#306998/#FFD43B/#E74C3C) and no ANYPLOT_THEME — images appear from a regenerated version.

Design Excellence (8/20)

  • DE-01: Aesthetic Sophistication (4/8) — Well-configured default. Clear community separation, degree-scaled nodes, hub labels. Not exceptional; standard seaborn scatter aesthetics.
  • DE-02: Visual Refinement (2/6) — All 4 spines kept (set to #CCCCCC instead of removing top/right). Legend has shadow=True and fancybox=True — unnecessary decoration. sns.set_theme(style='white') rather than recommended style='ticks' with full rc params.
  • DE-03: Data Storytelling (2/6) — Community structure is visible but there is no guided narrative. Hub nodes are labeled but no emphasis on inter-community bridges or the most central node. Data is displayed, not interpreted.

Spec Compliance (14/15)

  • SC-01: Plot Type (5/5) — Correct force-directed graph; Fruchterman-Reingold algorithm implemented inline with repulsive+attractive forces and simulated annealing cooling schedule.
  • SC-02: Required Features (4/4) — Node size scales by degree ✓, edge thickness by weight ✓, 150 iterations ✓, hub labels at 75th percentile threshold ✓.
  • SC-03: Data Mapping (3/3) — Nodes positioned by physics simulation; communities color-coded; edges represent connections; node size represents centrality.
  • SC-04: Title & Legend (2/3) — Images show "Organizational Network · network-force-directed · seaborn · anyplot.ai" — extra prefix violates required format {spec-id} · {library} · anyplot.ai. Code also uses 'pyplots.ai' (wrong brand). Legend labels correct.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Shows all aspects: 3 departments with community structure, hub-and-spoke topology, inter-community bridges, degree variation, weighted edges.
  • DQ-02: Realistic Context (5/5) — Corporate org network (Engineering/Marketing/Sales) is a real-world neutral scenario with plausible collaboration patterns.
  • DQ-03: Appropriate Scale (4/4) — 37 nodes (spec: 20-200), 35% intra / 5% inter connection probabilities, weights 0.3-1.0 — all realistic.

Code Quality (9/10)

  • CQ-01: KISS Structure (3/3) — Flat script, no functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) before all random calls.
  • CQ-03: Clean Imports (2/2) — Only matplotlib.pyplot, numpy, seaborn — all used.
  • CQ-04: Code Elegance (2/2) — FD algorithm as nested loops appropriate without networkx; custom legend via plt.scatter([],[]) is standard.
  • CQ-05: Output & API (0/1) — Saves as "plot.png" with facecolor="white". Must save as f"plot-{THEME}.png" after reading THEME = os.getenv("ANYPLOT_THEME", "light").

Library Mastery (4/10)

  • LM-01: Idiomatic Usage (3/5) — sns.scatterplot() with hue, size, sizes, edgecolor, linewidth is idiomatic. However, the bulk of the code (FD algorithm + edge drawing) is pure numpy/matplotlib; seaborn is only the final scatter renderer.
  • LM-02: Distinctive Features (1/5) — Seaborn contribution is essentially a styled scatter plot replicable with plt.scatter(). No FacetGrid, statistical functions, or the sns.set_theme() rc-dict pattern from the seaborn guide. Generic usage.

Score Caps Applied

  • None — DE-01=4 (above ≤2 threshold), CQ-04=2 (above 0 threshold). No caps triggered.

Strengths

  • Force-directed (Fruchterman-Reingold) algorithm implemented inline without networkx dependency — works correctly and deterministically
  • Realistic corporate network scenario with plausible intra/inter-community probabilities that create clear community structure
  • All spec features present: degree-scaled nodes, weight-scaled edges, 150 iterations, hub labels at 75th-percentile threshold
  • Node labels restricted to high-degree hubs — avoids clutter while surfacing key actors
  • np.random.seed(42) reproducibility; clean KISS flat script structure

Weaknesses

  • Code saves as plot.png with facecolor='white' and no ANYPLOT_THEME check — must read os.getenv('ANYPLOT_THEME', 'light') and save as plot-{THEME}.png with PAGE_BG/INK/INK_SOFT tokens throughout
  • Palette uses ['#306998', '#FFD43B', '#E74C3C']#306998 is explicitly forbidden Python Blue; must use Okabe-Ito ['#009E73', '#D55E00', '#0072B2']
  • Title format wrong: uses 'pyplots.ai' (should be 'anyplot.ai') and images show extra 'Organizational Network · ' prefix; required: 'network-force-directed · seaborn · anyplot.ai'
  • All 4 spines kept (colored #CCCCCC); legend has shadow=True, fancybox=True — remove top/right spines, drop shadow/fancybox for cleaner look
  • Hub annotation color='#333333' and stats text color='#666666' are hardcoded — dark-on-dark failure in dark theme; use INK_SOFT and INK_MUTED tokens
  • Hub label fontsize=12 is below the 16pt minimum for secondary text at 4800×2700px canvas; raise to at least 16pt
  • LM-02 low: use sns.set_theme(style='ticks', rc={...}) with full theme-adaptive chrome as seaborn's distinctive pattern per seaborn guide

Issues Found

  1. CQ-05 / VQ-07 CRITICAL: No theme adaptation — missing ANYPLOT_THEME env var, saves plot.png instead of plot-{THEME}.png, hardcoded facecolor='white'. Fix: add full theme block from seaborn.md guide at top of file.
  2. VQ-07 CRITICAL: Wrong palette (#306998 Python Blue, #FFD43B, #E74C3C). Fix: OKABE_ITO = ['#009E73', '#D55E00', '#0072B2'] and pass as palette=OKABE_ITO to sns.scatterplot().
  3. SC-04: Title format — fix to f"network-force-directed · seaborn · anyplot.ai" (no extra prefix, correct brand).
  4. DE-02: Remove top/right spines (ax.spines['top'].set_visible(False); ax.spines['right'].set_visible(False)), remove legend shadow/fancybox.
  5. DE-03: Emphasize inter-community bridge nodes (nodes with cross-community edges) with a distinct visual treatment — e.g., different marker shape or ring outline — to guide the viewer toward the insight.
  6. VQ-01: Raise hub annotation fontsize from 12 to 16pt minimum.

AI Feedback for Next Attempt

Fix in priority order: (1) Add full theme adaptation block — THEME = os.getenv('ANYPLOT_THEME','light'), derive PAGE_BG/INK/INK_SOFT/INK_MUTED, set via sns.set_theme(style='ticks', rc={...}), save as f'plot-{THEME}.png' with facecolor=PAGE_BG. (2) Switch palette to Okabe-Ito ['#009E73', '#D55E00', '#0072B2']. (3) Fix title to "network-force-directed · seaborn · anyplot.ai". (4) Remove top/right spines; drop shadow=True/fancybox=True from legend. (5) Use theme tokens for all annotation colors (INK_SOFT for hub labels, INK_MUTED for stats text). (6) Raise hub annotation fontsize to 16. (7) Optionally: add visual emphasis on bridge nodes (cross-community connections) for DE-03 storytelling.

Verdict: REJECTED

@github-actions github-actions Bot added quality:76 Quality score 76/100 ai-rejected Quality not OK, triggers update labels Apr 26, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels Apr 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor Author

🔧 Repair Attempt 1/3

Applied fixes based on AI review feedback.

Status: Repair completed, re-triggering review...


🤖 impl-repair

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 26, 2026

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): Warm off-white background (#FAF8F1) with a network of 37 nodes spread across the canvas. Engineering nodes appear in #009E73 (green, Okabe-Ito position 1) clustered left-center; Marketing nodes in #D55E00 (orange, position 2) on the right; Sales nodes in #0072B2 (blue, position 3) scattered at the periphery. Node sizes vary clearly by degree (larger = more connections). Bridge nodes have visible dark-ring outlines. Hub labels (Node 3, Node 4, Node 20, Node 21, Node 28, Node 30) appear above high-degree nodes in dark ink. Edges drawn in subtle gray (alpha=0.25) — non-distracting. Legend (top-left) shows department entries with counts and a bridge-node ring entry. Stats annotation at the bottom: "Nodes: 37 | Edges: 98 | Avg Degree: 5.3". All text is clearly readable against the light background — no light-on-light issues.

Dark render (plot-dark.png): Warm near-black background (#1A1A17). Title and axis labels render in light ink (#F0EFE8) — clearly readable. Legend text readable against the elevated dark legend box (#242420). Hub labels use the INK_SOFT token (light-colored on dark) — visible. Bridge node rings use the light INK token — clearly visible against the dark background. Data colors are identical to the light render: Engineering #009E73, Marketing #D55E00, Sales #0072B2. No dark-on-dark failures detected — all chrome tokens are theme-adaptive. Both renders pass readability.

Score: 86/100

Category Score Max
Visual Quality 28 30
Design Excellence 14 20
Spec Compliance 15 15
Data Quality 14 15
Code Quality 10 10
Library Mastery 5 10
Total 86 100

Visual Quality (28/30)

  • VQ-01: Text Legibility (7/8) — All sizes explicitly set: title=24pt, labels=20pt, ticks/annotations=16pt. Both themes fully readable. Minor: hub label offset (12pt) is tight at full resolution.
  • VQ-02: No Overlap (5/6) — No significant overlap. Hub labels use xytext offset positioning. Minor potential for label proximity in denser areas.
  • VQ-03: Element Visibility (6/6) — Nodes clearly visible (s=150–800), edges visible at alpha=0.25, bridge rings distinguishable.
  • VQ-04: Color Accessibility (2/2) — Okabe-Ito is CVD-safe; shape (ring) provides redundant encoding for bridge nodes.
  • VQ-05: Layout & Canvas (4/4) — Network fills canvas well. Legend top-left, stats bottom-center. tight_layout applied.
  • VQ-06: Axis Labels & Title (2/2) — "Force-Directed X/Y Position" are descriptive labels.
  • VQ-07: Palette Compliance (2/2) — Engineering=#009E73 (pos 1), Marketing=#D55E00 (pos 2), Sales=#0072B2 (pos 3). Light bg #FAF8F1, dark bg #1A1A17. Both renders theme-correct.

Design Excellence (14/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above defaults: bridge node rings, degree-scaled sizing, selective hub annotation, themed node edges (edgecolor=PAGE_BG). Intentional design choices. Not yet at publication quality.
  • DE-02: Visual Refinement (4/6) — Top/right spines removed, no grid (correct for network), axes ticks hidden, edge alpha creates depth. Keeping left+bottom spines feels structurally heavy for a floating graph layout.
  • DE-03: Data Storytelling (5/6) — Three simultaneous encodings (size=centrality, color=community, ring=bridge) create clear visual hierarchy. Hub labels guide attention to important nodes. Stats annotation provides quantitative context.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct force-directed graph with inline Fruchterman-Reingold physics simulation.
  • SC-02: Required Features (4/4) — Nodes, edges, weighted edge thickness, degree-based sizing, community structure all implemented.
  • SC-03: Data Mapping (3/3) — Force-directed X/Y positions correctly used. All 37 nodes visible.
  • SC-04: Title & Legend (3/3) — Code title: network-force-directed · seaborn · anyplot.ai (correct format). Legend: Engineering/Marketing/Sales with counts + Bridge node entry.

Data Quality (14/15)

  • DQ-01: Feature Coverage (5/6) — Community clustering, bridge nodes, degree centrality, weighted edges all shown. Edge weight variation (0.5–1.0 range) is too subtle to perceive visually.
  • DQ-02: Realistic Context (5/5) — Organizational network (Engineering/Marketing/Sales). Realistic connection probabilities (intra=0.35, inter=0.05). Neutral topic.
  • DQ-03: Appropriate Scale (4/4) — 37 nodes within spec's 20–200 range. 98 edges with avg degree 5.3 — realistic.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Flat script: imports → theme → data → FR layout → plotting → save.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set before data generation.
  • CQ-03: Clean Imports (2/2) — Only os, matplotlib.pyplot, numpy, seaborn — all used.
  • CQ-04: Code Elegance (2/2) — Clean Pythonic code. FR algorithm verbosity is appropriate. No fake UI elements.
  • CQ-05: Output & API (1/1) — Saves plot-{THEME}.png with dpi=300, bbox_inches='tight', facecolor=PAGE_BG.

Library Mastery (5/10)

  • LM-01: Idiomatic Usage (3/5) — sns.scatterplot used correctly with hue, size, palette, edgecolor — idiomatic seaborn for categorical scatter. However, the bulk of the visualization (edge drawing, bridge rings, annotations, the layout algorithm) is pure matplotlib, limiting seaborn's contribution.
  • LM-02: Distinctive Features (2/5) — Uses seaborn's hue+size+palette combination for community/degree encoding, which is a genuine seaborn strength. Scope is limited since network drawing relies on matplotlib primitives.

Score Caps Applied

  • None

Strengths

  • Complete force-directed layout via inline Fruchterman-Reingold with deterministic seed — correct and self-contained
  • Bridge node detection and ring highlighting is a meaningful analytical feature not just visual decoration
  • Degree-based node sizing + color-coded communities + bridge rings = three clear, simultaneous visual encodings
  • Full theme-adaptive chrome — both renders pass readability checks, no dark-on-dark failures
  • Perfect spec compliance (15/15) and code quality (10/10)

Weaknesses

  • Seaborn's role is confined to one scatter layer; edges, rings, annotations, and the layout algorithm are pure matplotlib — library mastery is limited
  • Left+bottom spines retained, which feels structural for a floating network graph; ax.axis('off') or removing all spines would look cleaner
  • Edge weight visual range (2–3pt from weight 0.5–1.0) is too narrow to clearly communicate weight variation

Issues Found

  1. LM-01/LM-02 LOW: Seaborn limited to one scatter call; most work is matplotlib
    • Fix: Consider using seaborn more distinctively — e.g., use sns.kdeplot for community density contours in the background, or integrate a seaborn-styled marginal/color bar for degree distribution
  2. DE-02 PARTIAL: Left and bottom spines retained, which adds frame weight to a floating graph
    • Fix: Remove all spines for a cleaner floating-network aesthetic, or color them at lower opacity to recede

AI Feedback for Next Attempt

The implementation is solid — themes, palette, spec compliance, and code quality are all correct. To reach 90+, focus on two areas: (1) Library mastery: give seaborn a more distinctive role — consider adding sns.kdeplot density contours behind community clusters to show group density, which is a uniquely seaborn contribution that complements the scatter layer; (2) Design refinement: remove all spines (ax.spines[s].set_visible(False) for all four) and increase the edge weight visual range (e.g., multiply weight by 4–5 instead of 2) so weight variation is perceptible. These two changes alone could push DE-02 to 6/6 and LM-01 to 4/5, adding ~4–5 points.

Verdict: REJECTED

@github-actions github-actions Bot added quality:86 Quality score 86/100 ai-approved Quality OK, ready for merge labels Apr 26, 2026
@github-actions github-actions Bot merged commit 94f5d21 into main Apr 26, 2026
3 checks passed
@github-actions github-actions Bot deleted the implementation/network-force-directed/seaborn branch April 26, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-approved Quality OK, ready for merge ai-attempt-1 First repair attempt quality:76 Quality score 76/100 quality:86 Quality score 86/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants