Skip to content

feat(plotnine): implement tree-phylogenetic#6757

Merged
MarkusNeusinger merged 4 commits into
mainfrom
implementation/tree-phylogenetic/plotnine
May 15, 2026
Merged

feat(plotnine): implement tree-phylogenetic#6757
MarkusNeusinger merged 4 commits into
mainfrom
implementation/tree-phylogenetic/plotnine

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: tree-phylogenetic - python/plotnine

Implements the python/plotnine version of tree-phylogenetic.

File: plots/tree-phylogenetic/implementations/python/plotnine.py

Parent Issue: #3070


🤖 impl-generate workflow

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 15, 2026

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): The plot displays a rectangular phylogenetic tree on a warm off-white (#FAF8F1) background. Eight primate species are arranged vertically (Lemur, Baboon, Macaque, Gibbon, Orangutan, Gorilla, Chimpanzee, Human), each with a green (#009E73) marker at the leaf position. Thick colored branches (size 2.5) represent clade relationships, with each clade assigned a distinct Okabe-Ito color (green, orange, blue, pink, yellow, etc.). The title "tree-phylogenetic · plotnine · anyplot.ai" is displayed in dark text at the top. A legend box on the right shows all clade names and their corresponding colors. A scale bar at the bottom indicates "0.1 substitutions/site" in dark gray text. All text—title, axis label, species names, legend entries, and scale bar annotation—is clearly readable against the light background with good contrast. The overall layout is clean and professional.

Dark render (plot-dark.png): The same phylogenetic tree is rendered on a warm near-black (#1A1A17) background with light text throughout. The title, axis label, species names, legend text, and scale bar annotation all use light gray text colors that are clearly readable against the dark background. Critically, the data colors (branch colors and leaf markers) are identical to the light render—only the chrome (background, text, legend frame) has adapted to the dark theme. The green (#009E73) leaf markers remain vibrant and distinct from the background. No dark-on-dark failures are present; all text is legible. The visual hierarchy and tree structure are preserved exactly as in the light render.

Score: 88/100

Category Score Max
Visual Quality 30 30
Design Excellence 11 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 7 10
Total 88 100

Visual Quality (30/30)

  • VQ-01: Text Legibility (8/8) — Font sizes explicitly set for all elements (title=24, labels=14-16, legend=12). Readable in both light and dark themes.
  • VQ-02: No Overlap (6/6) — Species labels use nudge_x=0.02 to avoid marker overlap. All text is clearly distinguishable.
  • VQ-03: Element Visibility (6/6) — Leaf markers (5pt), branches (size=2.5), and labels are all clearly visible with good contrast.
  • VQ-04: Color Accessibility (2/2) — Okabe-Ito palette is CVD-safe. No red-green-only signals. Adequate contrast throughout.
  • VQ-05: Layout & Canvas (4/4) — 16:9 proportion (figsize=(16,9)). Nothing cut off. Appropriate margins and whitespace.
  • VQ-06: Axis Labels & Title (2/2) — Title follows spec format. X-axis label "Evolutionary Distance (substitutions per site)" includes units.
  • VQ-07: Palette Compliance (2/2) — Leaf markers use #009E73 (brand green). Clade branches follow Okabe-Ito order. Plot backgrounds are #FAF8F1 (light) / #1A1A17 (dark). Both renders are theme-correct.

Design Excellence (11/20)

  • DE-01: Aesthetic Sophistication (4/8) — Functional phylogenetic tree with clade-specific coloring. Standard rectangular (cladogram) layout. No particularly novel design choices. Uses default Okabe-Ito palette without additional customization.
  • DE-02: Visual Refinement (3/6) — Uses theme_void() for clean minimal aesthetics. Scale bar is a professional touch. Legend positioning is appropriate. However, fairly standard refinement for phylogenetic trees—no extra polish.
  • DE-03: Data Storytelling (4/6) — Clear hierarchical structure showing evolutionary branching. Color coding helps distinguish clades. Straightforward presentation without emphasis techniques or focal point manipulation.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct phylogenetic tree visualization. Rectangular (cladogram) layout. Branch lengths proportional to evolutionary distance.
  • SC-02: Required Features (4/4) — Hierarchical relationships shown. Branch lengths proportional. Species labels present. Scale bar included.
  • SC-03: Data Mapping (3/3) — X-axis represents evolutionary distance. Y-axis positions species appropriately. All 8 species and clade relationships displayed.
  • SC-04: Title & Legend (3/3) — Title format correct: "tree-phylogenetic · plotnine · anyplot.ai". Legend shows all clade names with colors.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Eight primate species shown. Multiple clade levels (Strepsirrhini, Haplorrhini, Catarrhini, etc.). Demonstrates phylogenetic relationships and divergence.
  • DQ-02: Realistic Context (5/5) — Primate evolution based on mitochondrial DNA is scientifically plausible. Species selection and relationships are accurate. Not controversial.
  • DQ-03: Appropriate Scale (4/4) — Branch lengths in realistic units (substitutions per site). Scale bar provided (0.1 units). Values appropriate for evolutionary distances.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — No unnecessary functions or classes. Direct data creation and plotting. Clean and simple.
  • CQ-02: Reproducibility (2/2) — Uses np.random.seed(42). All data explicitly defined. Deterministic output.
  • CQ-03: Clean Imports (2/2) — All imports used. No extraneous imports. Organized import structure.
  • CQ-04: Code Elegance (2/2) — Appropriate complexity. No fake UI or matplotlib workarounds. Direct plotnine usage.
  • CQ-05: Output & API (1/1) — Saves as plot-{THEME}.png with dpi=300. Uses current plotnine API.

Library Mastery (7/10)

  • LM-01: Idiomatic Usage (5/5) — Excellent use of ggplot(), aes(), geom_(), theme(), element_() functions. Idiomatic plotnine patterns throughout.
  • LM-02: Distinctive Features (2/5) — Uses theme_void(), element_rect/text for theme customization, and annotate() for scale bar. Fairly standard plotnine features—no advanced techniques like faceting, twin axes, or custom projections.

Score Caps Applied

  • None — All criteria passed thresholds. No caps triggered.

Strengths

  • Accurate phylogenetic tree showing correct evolutionary relationships among primates
  • Excellent theme-adaptive implementation with perfect legibility in both light and dark themes
  • Clean, minimal aesthetics with theme_void() appropriate for this visualization type
  • Professional scale bar annotation that adds scientific credibility
  • All text legible and properly sized for the large canvas
  • Solid Okabe-Ito palette application across clade colors

Weaknesses

  • Design is functional but not particularly sophisticated—standard phylogenetic tree presentation without distinctive visual choices
  • No attempt at exploring alternative layouts (radial/circular trees mentioned in spec as option)
  • Limited use of advanced plotnine features beyond basic geoms and themes

Issues Found

  1. DE-01 LOW: Generic cladogram styling without exploring design variations. The implementation uses the most straightforward rectangular layout; no attempt at circular/radial layouts mentioned in the spec as alternatives.

    • Suggestion: Consider adding a second layout option or more sophisticated visual hierarchy through size variation or emphasis
  2. DE-02 MEDIUM: Minimal visual refinement beyond removing spines. While clean, the plot lacks sophisticated styling choices (alpha-blending, edge definition, advanced typography).

    • Suggestion: Could benefit from edge highlighting on markers or gradient effects to increase polish

AI Feedback for Next Attempt

The implementation is correct and readable, but design excellence is modest. To increase the DE scores: (1) explore circular/radial tree layouts as mentioned in the spec; (2) add visual refinement through edge-highlighted markers or subtle alpha-blending; (3) create stronger visual hierarchy through size or color emphasis of key clades. Current score reflects solid technical execution but limited design sophistication.

Verdict: APPROVED

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

🔧 Repair Attempt 1/4

Applied fixes based on AI review feedback.

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


🤖 impl-repair

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 15, 2026

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): The phylogenetic tree displays on a warm off-white background (#FAF8F1) as specified. The title "tree-phylogenetic · plotnine · anyplot.ai" is rendered in dark ink (#1A1A17) and is clearly readable. All eight species labels (Lemur, Human, Chimpanzee, Gorilla, Orangutan, Gibbon, Macaque, Baboon) are positioned to the right of their leaf nodes with proper nudging to avoid overlap, all readable. The scale bar annotation at lower left ("0.1 substitutions/site") uses secondary text color (#4A4A44) for proper visual hierarchy. The phylogenetic tree structure consists of color-coded horizontal branch segments representing evolutionary relationships, with the first series (Strepsirrhini) correctly using the brand green (#009E73). Green leaf markers (circles) mark species endpoints. The legend box positioned upper right displays all 11 clades with their assigned Okabe-Ito colors. All text and data elements are fully readable with excellent contrast against the light background.

Dark render (plot-dark.png): The same phylogenetic tree displays on a warm near-black background (#1A1A17) with proper theme adaptation. The title and all text elements are rendered in light tones (#F0EFE8 for primary, #B8B7B0 for secondary) ensuring perfect readability against the dark surface. The tree structure is identical to the light render — all branch colors (Okabe-Ito positions 1–7) remain constant across themes, confirming proper theme-adaptive implementation. The first series (Strepsirrhini) maintains #009E73, leaf markers are identical, and the scale bar is appropriately adapted. No dark-on-dark failures detected. Both renders verified for color consistency and legibility.

Score: 90/100

Category Score Max
Visual Quality 29 30
Design Excellence 15 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 6 10
Total 90 100

Visual Quality (29/30)

  • VQ-01: Text Legibility (8/8) — All font sizes explicitly set and readable in both themes
  • VQ-02: No Overlap (6/6) — Species labels properly nudged, no collisions
  • VQ-03: Element Visibility (6/6) — 8-species tree with appropriate density, all elements visible
  • VQ-04: Color Accessibility (2/2) — Okabe-Ito palette, CVD-safe
  • VQ-05: Layout & Canvas (4/4) — Good proportions, all elements fit within bounds
  • VQ-06: Axis Labels & Title (1/2) — Title correct, but x-axis label hidden by theme_void()
  • VQ-07: Palette Compliance (2/2) — First series #009E73, backgrounds correct, both themes adapted

Design Excellence (15/20)

  • DE-01: Aesthetic Sophistication (6/8) — Professional clade-based color scheme, above generic defaults
  • DE-02: Visual Refinement (5/6) — Clean legend, effective use of theme_void(), professional scale bar
  • DE-03: Data Storytelling (4/6) — Clear hierarchical organization, functional but somewhat conventional

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct phylogenetic tree diagram
  • SC-02: Required Features (4/4) — Hierarchical structure, proportional branch lengths, leaf labels, scale bar
  • SC-03: Data Mapping (3/3) — X-axis shows evolutionary distance, Y-axis shows species arrangement
  • SC-04: Title & Legend (3/3) — Correct title format, complete legend with all clades

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Shows all phylogenetic aspects: hierarchy, distances, diversity, clade differentiation
  • DQ-02: Realistic Context (5/5) — Realistic primate tree based on mitochondrial DNA, educationally sound
  • DQ-03: Appropriate Scale (4/4) — 8 species readable, branch lengths sensible for evolutionary distances

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — No functions/classes, straightforward procedural implementation
  • CQ-02: Reproducibility (2/2) — Uses np.random.seed(42) for deterministic output
  • CQ-03: Clean Imports (2/2) — Only necessary imports, all used
  • CQ-04: Code Elegance (2/2) — No fake UI, appropriate plotnine idioms
  • CQ-05: Output & API (1/1) — Saves as plot-{THEME}.png, current API

Library Mastery (6/10)

  • LM-01: Idiomatic Usage (4/5) — Proper ggplot() paradigm, correct geom selection, sound grammar of graphics
  • LM-02: Distinctive Features (2/5) — Standard plotnine features (theme_void, scale_color_manual), limited advanced customization

Score Caps Applied

  • None — No caps triggered

Strengths

  • Excellent theme adaptation with correct palette usage in both light and dark renders
  • All text elements perfectly readable in both themes — no contrast or visibility issues
  • Proper phylogenetic tree structure with clear hierarchical organization and species relationships
  • Professional scale bar annotation with correct units
  • Clean, deterministic code with proper seed for reproducibility
  • All species labels properly positioned without overlap
  • Correct Okabe-Ito palette implementation with first series as #009E73

Weaknesses

  • Design Excellence could be elevated: consider unique clade visualization techniques (gradient fills, edge cases, or symbolic emphasis)
  • Library Mastery: minimal use of distinctive plotnine features — uses standard geoms without advanced customization
  • VQ-06: X-axis label defined in labs() but hidden by theme_void() — consider alternative for distance encoding
  • Aesthetic could benefit from more sophisticated visual hierarchy beyond color differentiation

Issues Found

  1. VQ-06 MINOR: X-axis label "Evolutionary Distance (substitutions per site)" is defined in labs() but hidden by theme_void() — the label doesn't appear in the final render, reducing VQ-06 from 2/2 to 1/2.

    • Fix: Either (a) add visible axis text/scale on one axis while keeping theme_void() aesthetic, or (b) enhance the scale bar annotation to more explicitly encode distance values.
  2. DE-01 MODERATE: Design is professional but somewhat conventional for a phylogenetic tree visualization.

    • Fix: Consider more sophisticated visual techniques — perhaps branch thickness proportional to distance (if not already encoded in segment coordinates), or subtle gradient fills on clades, or symbolic emphasis for specific lineages.
  3. LM-02 MINOR: Limited showcase of distinctive plotnine features.

    • Fix: Explore plotnine-specific capabilities: custom stat layers for enhanced data processing, or coordinate system overrides, or layer-specific aesthetic mappings to create visual depth.

AI Feedback for Next Attempt

The implementation is strong and meets all spec requirements with excellent theme adaptation and readable plots. To improve the score:

  1. Address the hidden x-axis label issue (VQ-06) by making distance encoding visible in the render
  2. Elevate Design Excellence by introducing more sophisticated visual techniques specific to phylogenetic trees (e.g., branch styling proportional to distance, gradient fills on clades, or symbolic emphasis)
  3. Showcase more advanced plotnine features to improve Library Mastery

Verdict: APPROVED

@github-actions github-actions Bot added quality:90 Quality score 90/100 ai-approved Quality OK, ready for merge and removed quality:88 Quality score: 88/100 labels May 15, 2026
@MarkusNeusinger MarkusNeusinger merged commit 43ba1e2 into main May 15, 2026
@MarkusNeusinger MarkusNeusinger deleted the implementation/tree-phylogenetic/plotnine branch May 15, 2026 01:20
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:90 Quality score 90/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant