Skip to content

feat(seaborn): implement contour-map-geographic#7550

Merged
MarkusNeusinger merged 5 commits into
mainfrom
implementation/contour-map-geographic/seaborn
May 20, 2026
Merged

feat(seaborn): implement contour-map-geographic#7550
MarkusNeusinger merged 5 commits into
mainfrom
implementation/contour-map-geographic/seaborn

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Implementation: contour-map-geographic - python/seaborn

Implements the python/seaborn version of contour-map-geographic.

File: plots/contour-map-geographic/implementations/python/seaborn.py

Parent Issue: #3772


🤖 impl-generate workflow

github-actions Bot added 2 commits May 20, 2026 22:43
Regen from quality 91. Addressed:
- Canvas: fixed figsize=(8,4.5) dpi=400 → exact 3200×1800 px (was figsize=(16,9) producing wrong dimensions)
- Theme: added full ANYPLOT_THEME support with PAGE_BG, INK, INK_SOFT, ELEVATED_BG, OCEAN, LAND, COAST tokens
- Save: output now plot-{THEME}.png (was bare plot.png); removed bbox_inches='tight' per seaborn library rule
- Coastlines: added subtle land fill (LAND color) to enhance geographic context (was outline-only)
- Title: updated to include 'python' language token and anyplot.ai branding; switched to fig.suptitle() to prevent overflow with equal-aspect map
- sns.set_theme: updated to use proper rc dict with theme-adaptive tokens
- Colorbar: all chrome (label, ticks, outline) now theme-adaptive
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 20, 2026

AI Review - Attempt 1/3

Image Description

Light render (plot-light.png): The plot renders on a warm off-white #FAF8F1 background. A world map fills the canvas with a light-blue ocean fill and a sandy-beige land fill; the filled contours (RdYlBu_r) show temperature anomalies ranging from deep blue (−2°C) to warm red (4.5°C) over oceanic regions. Contour isoline overlays are drawn in dark ink with inline %.1f°C labels. A colorbar on the right is labeled "Temperature Anomaly (°C)". Axis labels "Longitude (°)" and "Latitude (°)" are readable at 10pt; tick labels at 8pt are clear. Title is dark bold text on the off-white background. All text is fully readable against the light background. Geographic aspect ratio is correct.

Dark render (plot-dark.png): The background is near-black #1A1A17; the ocean fill becomes a very dark navy (#182633) and the continent fill becomes a dark warm olive (#5A5040). The filled contour data colors (RdYlBu_r diverging from blue to red) are visually identical to the light render — only chrome flips. Title, axis labels, and tick labels render in light cream #F0EFE8/#B8B7B0 and are clearly readable against the dark background. Contour labels are also displayed in the light INK color. No dark-on-dark text failures observed. Colorbar label and tick labels are legible. All text is readable against the dark background.

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

Score: 82/100

Category Score Max
Visual Quality 26 30
Design Excellence 12 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 4 10
Total 82 100

Visual Quality (26/30)

  • VQ-01: Text Legibility (7/8) — All font sizes explicitly set (title 11pt bold, axes 10pt, ticks/contour labels 8pt). Balanced proportions. Inline contour labels are small but appropriate for geographic maps. Minor: could be slightly larger for mobile readability.
  • VQ-02: No Overlap (5/6) — Title, axis labels, ticks, and colorbar are clean. Minor crowding among inline contour labels in dense regions over mid-latitudes.
  • VQ-03: Element Visibility (5/6) — Filled contours, contour lines, and coastline polygons are all clearly visible. Contour lines (alpha=0.55) are slightly muted; slightly more prominent lines would help at small sizes.
  • VQ-04: Color Accessibility (2/2) — RdYlBu_r is a perceptually-uniform diverging colormap safe for CVD; blue-red poles are distinguishable via luminance as well as hue.
  • VQ-05: Layout & Canvas (4/4) — Canvas 3200×1800 confirmed. Equal aspect ratio is geographically correct. Colorbar placement is proportional. tight_layout() produces clean margins.
  • VQ-06: Axis Labels & Title (2/2) — "Longitude (°)", "Latitude (°)", and colorbar label "Temperature Anomaly (°C)" all include units.
  • VQ-07: Palette Compliance (1/2) — Continuous diverging data is correctly handled (not Okabe-Ito). However, the style guide mandates BrBG for diverging data; RdYlBu_r is used instead. Backgrounds (#FAF8F1 / #1A1A17) and chrome colors are theme-correct in both renders.

Design Excellence (12/20)

  • DE-01: Aesthetic Sophistication (5/8) — Above-average sophistication: theme-adaptive ocean/land/coast fill colors, geographic aspect lock, and a two-layer contour (filled + lines + labels) approach add professional polish. Not exceptional enough for 6+ on a first attempt.
  • DE-02: Visual Refinement (4/6) — Top/right spines removed; subtle 10%-alpha grid; colorbar outline color matches chrome tokens. Could further refine: the land fill in the dark theme is a flat dark olive that can look heavy; a finer spine-width on the geographic frame would add polish.
  • DE-03: Data Storytelling (3/6) — The Arctic-amplification pattern (higher anomalies at poles) is embedded in the data and visible in the plot. The diverging colormap centres on zero, making warming vs. cooling intuitive. But there is no title annotation, callout, or emphasis technique guiding the viewer to the key insight.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct: filled contours (contourf) + contour lines (contour) overlaid on a geographic basemap with coastlines and land fill.
  • SC-02: Required Features (4/4) — Basemap with coastlines ✓; labeled contour lines ✓; filled contours ✓; colormap appropriate to data type ✓; colorbar legend ✓; meaningful intervals ✓.
  • SC-03: Data Mapping (3/3) — Longitude on X, latitude on Y, temperature anomaly encoded in color. Grid of 72×32 points covers global domain.
  • SC-04: Title & Legend (3/3) — Title: "Global Temperature Anomaly · contour-map-geographic · python · seaborn · anyplot.ai" — correct {Descriptive} · {spec-id} · {lang} · {lib} · anyplot.ai format. No separate legend needed (colorbar serves this role).

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Shows positive and negative anomalies, geographic variation across latitudes, Arctic amplification effect, and spatial noise — full feature coverage.
  • DQ-02: Realistic Context (5/5) — Global temperature anomaly is a real, neutral scientific topic. Arctic amplification is an established physical phenomenon. No controversial content.
  • DQ-03: Appropriate Scale (4/4) — Range −2 to +4.5°C is realistic for contemporary observed anomalies. Pole-to-equator gradient pattern matches real-world Arctic amplification observations.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Linear: imports → tokens → data → plot → save. No functions or classes.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) set before data generation.
  • CQ-03: Clean Imports (2/2) — Only os, matplotlib.pyplot, numpy, and seaborn imported; all are used.
  • CQ-04: Code Elegance (2/2) — The WORLD_COASTLINES literal is verbose but necessary (no external geo library used). Code is clean and idiomatic; no fake UI elements.
  • CQ-05: Output & API (1/1) — Saves as plot-{THEME}.png with dpi=400; no bbox_inches='tight'.

Library Mastery (4/10)

  • LM-01: Idiomatic Usage (3/5) — Seaborn's sns.set_theme() with full rc-dict is used correctly for theme-adaptive chrome. However, all actual plotting is done via matplotlib (ax.contourf, ax.contour, ax.clabel, ax.fill). Seaborn's own plot functions (e.g. sns.kdeplot for contour-like output) are not used, making this largely a matplotlib plot with seaborn theming.
  • LM-02: Distinctive Features (1/5) — No distinctive seaborn feature is leveraged in the visualization itself. The entire rendering pipeline is matplotlib. Generic usage: could be a pure matplotlib implementation with minor syntax changes.

Score Caps Applied

  • None applied. (DE-01=5 > 2, CQ-04=2 > 0 — no caps triggered.)

Strengths

  • Perfect spec compliance: contourf + contour lines + clabels + colorbar + geographic basemap all present.
  • High-quality realistic data: Arctic amplification modeled correctly with a physically plausible anomaly pattern.
  • Excellent theme adaptation: ocean/land/coast colors flip correctly between light and dark themes; all chrome tokens properly threaded through.
  • Canvas dimensions exactly 3200×1800 px; no bbox_inches drift.
  • Clean code structure with seed, no functions/classes, all imports used.

Weaknesses

  • Wrong diverging colormap: RdYlBu_r is used for diverging data instead of the mandated BrBG (style guide: "Diverging: BrBG from ColorBrewer — anyplot default for diverging"). Replace cmap="RdYlBu_r" with cmap="BrBG_r" (reversed so negative anomalies are brown/warm and positive are green/teal, or keep BrBG with positive = green).
  • Seaborn barely used for plotting: the entire rendering layer is matplotlib; no seaborn plot function (kdeplot, heatmap, or similar) is invoked. LM-01/LM-02 scores are low as a result.
  • Contour line alpha (0.55) makes them somewhat indistinct at smaller display sizes — increase to 0.7–0.8 for better visibility.
  • No data-storytelling emphasis: consider adding a brief subtitle or label callout highlighting the Arctic amplification signal (e.g., a horizontal annotation line at 66°N with a note "Arctic amplification zone").

Issues Found

  1. VQ-07 LOW — Wrong diverging colormap: RdYlBu_r is not the mandated palette. Fix: cmap="BrBG_r" (reversed BrBG keeps the same warm=negative / cool=positive convention for temperature anomalies, or leave non-reversed if positive anomalies should map to the warm brown end).
  2. LM-01/LM-02 LOW — Minimal seaborn usage: All plotting is done via matplotlib. Fix: consider using sns.kdeplot for contour density layers on ocean data, or acknowledge this as a matplotlib-heavy implementation and ensure sns.set_theme() config is maximally leveraged (e.g., using sns.despine() for spine removal instead of manual spine toggling).
  3. DE-03 LOW — No storytelling emphasis: The Arctic amplification pattern is visible but unmarked. Fix: add a one-line ax.axhline(66.5, linestyle='--', color=INK_SOFT, linewidth=0.8, alpha=0.5, zorder=5) with ax.text() label, or a fig.text() subtitle noting the polar amplification signal.

AI Feedback for Next Attempt

Switch the diverging colormap from RdYlBu_r to BrBG_r (the mandated anyplot default for diverging data) to fix VQ-07. Increase contour line alpha from 0.55 to ~0.75 for better visibility at small display sizes. To improve DE-03, add a subtle dashed line at Arctic Circle (66.5°N) with a small label noting "Arctic amplification" — this turns implicit information into an explicit data story without annotation overload. For LM, consider replacing the manual spine calls (ax.spines[...].set_visible(False)) with the idiomatic sns.despine(ax=ax).

Verdict: REJECTED

@github-actions github-actions Bot added quality:82 Quality score 82/100 ai-rejected Quality not OK, triggers update labels May 20, 2026
@github-actions github-actions Bot added ai-attempt-1 First repair attempt and removed ai-rejected Quality not OK, triggers update labels May 20, 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 20, 2026

AI Review - Attempt 2/3

Image Description

Light render (plot-light.png): Displayed on a warm off-white #FAF8F1 background. The main geographic map shows filled contours using BrBG_r — warm brown tones cover positive temperature anomalies at high latitudes (Arctic), teal covers negative anomalies in tropical ocean regions. Contour lines overlay in dark ink with inline %.1f°C labels. Land masses are rendered in sandy tan (#D8CEA8) and ocean in light blue (#C4D8EC), with coastline outlines. A colorbar on the right of the map shows the range from -2 to 4+°C and is labeled "Temperature Anomaly (°C)". The right side panel shows the zonal mean profile in orange (#D55E00, Okabe-Ito position 2) with a positive-anomaly fill, a dashed zero reference line, and a dotted 60°N boundary with "Arctic Amplification" annotation. Title, axis labels, tick labels, colorbar text, and panel labels are all dark and clearly legible. Inline contour labels at 8pt and the "Arctic Amplification" annotation at 6pt are small but technically readable at full resolution. All text is readable against the light background.

Dark render (plot-dark.png): Displayed on warm near-black #1A1A17. The title and all axis labels, tick labels, colorbar text, and panel labels correctly flip to light colors (#F0EFE8 / #B8B7B0) — no dark-on-dark failures. Land masses become dark brown (#5A5040) and ocean becomes dark blue-gray (#182633). The contour fill colors (BrBG_r) are identical to the light render — only the geographic chrome (land, ocean, spine, background) flips. Contour labels use INK token (#F0EFE8 in dark mode) and are visible against the filled contour surface. The orange zonal mean line (#D55E00) is unchanged and clearly visible. Both renders pass the theme-readability check with no dark-on-dark or light-on-light failures.

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

Score: 83/100

Category Score Max
Visual Quality 25 30
Design Excellence 13 20
Spec Compliance 15 15
Data Quality 15 15
Code Quality 10 10
Library Mastery 5 10
Total 83 100

Visual Quality (25/30)

  • VQ-01: Text Legibility (6/8) — Title, axis labels, tick labels, colorbar all readable in both themes. Inline contour labels at 8pt and "Arctic Amplification" annotation at 6pt are small; marginal mobile readability.
  • VQ-02: No Overlap (5/6) — Inline clabels well-placed by matplotlib. Minor crowding near some contour labels at coastline boundaries.
  • VQ-03: Element Visibility (5/6) — Filled contours, contour lines, coastlines, colorbar, and zonal profile all clearly visible. Small contour labels slightly limit clarity.
  • VQ-04: Color Accessibility (2/2) — BrBG_r is CVD-safe. D55E00 (Okabe-Ito Add Claude Code GitHub Workflow #2) is accessible. No red-green reliance as sole signal.
  • VQ-05: Layout & Canvas (3/4) — Canvas gate passed (3200×1800). Two-panel 4:1 width ratio is well-proportioned. tight_layout() used with no bbox_inches='tight' in savefig — correct.
  • VQ-06: Axis Labels & Title (2/2) — Descriptive title with required format and prefix. Axis labels, colorbar, and zonal panel all include appropriate labels with units.
  • VQ-07: Palette Compliance (2/2) — BrBG_r for diverging temperature data is correct. Highlight D55E00 is Okabe-Ito Add Claude Code GitHub Workflow #2. Backgrounds #FAF8F1/#1A1A17 correct. Chrome flips correctly in both renders.

Design Excellence (13/20)

  • DE-01: Aesthetic Sophistication (5/8) — Two-panel layout with theme-adaptive geographic colors (ocean/land adapt to theme) and a meaningful zonal side panel raises this above default. Simplified blocky coastlines limit geographic authenticity.
  • DE-02: Visual Refinement (4/6) — Top/right spines removed from map; top/right/left spines removed from zonal panel. Grid at 10% alpha. Colorbar and contour styling refined. Intentional use of alpha throughout (0.85 contourf, 0.75 contour lines, 0.15 fill).
  • DE-03: Data Storytelling (4/6) — Arctic Amplification annotation with 60°N reference line delivers a clear focal point. fill_betweenx highlights positive anomaly zone. BrBG_r direction is intuitive (brown=warming). Two panels tell a coherent story from spatial to zonal.

Spec Compliance (15/15)

  • SC-01: Plot Type (5/5) — Correct: contour lines on geographic basemap with lat/lon coordinates and coastlines.
  • SC-02: Required Features (4/4) — All spec requirements met: smooth contour lines, inline labels, filled contours, colorbar, BrBG colormap, meaningful intervals.
  • SC-03: Data Mapping (3/3) — Latitude on y-axis, longitude on x-axis. Full global range. Temperature anomaly mapped to color.
  • SC-04: Title & Legend (3/3) — "Global Temperature Anomaly · contour-map-geographic · python · seaborn · anyplot.ai" — correct format with descriptive prefix. Colorbar labeled with units.

Data Quality (15/15)

  • DQ-01: Feature Coverage (6/6) — Filled contours, contour lines with inline labels, coastlines, colorbar, bonus zonal mean panel with Arctic Amplification signal.
  • DQ-02: Realistic Context (5/5) — Global temperature anomaly is an established scientific domain. Arctic amplification pattern is realistic. Neutral topic.
  • DQ-03: Appropriate Scale (4/4) — Global lat/lon coverage, -2 to 4.5°C anomaly range matches observed data, 72×32 grid is adequate.

Code Quality (10/10)

  • CQ-01: KISS Structure (3/3) — Flat script, no functions/classes. Clean linear flow with logical sections.
  • CQ-02: Reproducibility (2/2) — np.random.seed(42) present.
  • CQ-03: Clean Imports (2/2) — Only os, matplotlib.pyplot, numpy, seaborn — all used.
  • CQ-04: Code Elegance (2/2) — Appropriate complexity for a geographic plot. No fake interactivity.
  • CQ-05: Output & API (1/1) — plt.savefig(f'plot-{THEME}.png', dpi=400, facecolor=PAGE_BG) — correct format, no bbox_inches='tight'.

Library Mastery (5/10)

  • LM-01: Idiomatic Usage (3/5) — sns.set_theme with custom RC params is the correct seaborn pattern. sns.lineplot(errorbar=None) for the zonal mean is idiomatic. Geographic contours via matplotlib directly is appropriate given seaborn's scope.
  • LM-02: Distinctive Features (2/5) — Seaborn's role is primarily theme management plus one sns.lineplot for the sidebar. The core geographic contour visualization is entirely matplotlib. Limited seaborn-distinctive contribution.

Score Caps Applied

  • None

Strengths

  • Excellent spec compliance — all required features implemented: filled contours (BrBG_r), contour lines with inline labels, colorbar with units, geographic basemap with coastlines, meaningful contour intervals
  • Two-panel composition elegantly connects spatial distribution (map) to global pattern (zonal mean) with Arctic Amplification annotation and 60°N reference line delivering clear data storytelling
  • Perfect theme adaptation — all chrome elements use INK/INK_SOFT tokens; both light and dark renders are fully readable with no dark-on-dark or light-on-light failures
  • Perfect code quality — reproducible (seed=42), clean imports, flat script structure, correct output filename format

Weaknesses

  • Inline contour labels at 8pt and "Arctic Amplification" annotation at 6pt are small; at ~400px mobile width these become ~5px and ~4px respectively — increase contour labels to 9pt and annotation to 7–8pt for better mobile readability
  • Simplified coastline polygons produce blocky, geometrically crude continent shapes; while functional, these reduce geographic authenticity and visual polish
  • Library Mastery is limited — seaborn functions primarily as a theme wrapper (sns.set_theme) plus sns.lineplot for the sidebar; the core geographic visualization is entirely matplotlib

Issues Found

  1. VQ-01 MINOR: Small annotation text (6pt "Arctic Amplification") is marginal for mobile readability
    • Fix: Increase "Arctic Amplification" annotation fontsize from 6pt to 7–8pt; increase contour clabels fontsize from 8pt to 9pt
  2. LM-02 LOW: seaborn used primarily as theme wrapper rather than for core visualization
    • Fix: Consider using seaborn's kdeplot or other seaborn-native techniques where applicable within the geographic context

AI Feedback for Next Attempt

The implementation is solid and all spec features are present. To push the score higher: (1) increase the "Arctic Amplification" annotation fontsize from 6pt to at least 7pt and contour clabels from 8pt to 9pt for mobile readability; (2) consider whether any additional seaborn-native techniques can be incorporated beyond sns.lineplot for the zonal mean — e.g. sns.kdeplot for a smoothed zonal density overlay. The simplified coastlines are a creative constraint worth keeping as-is.

Verdict: APPROVED

@github-actions github-actions Bot added quality:83 Quality score 83/100 ai-approved Quality OK, ready for merge and removed quality:82 Quality score 82/100 labels May 20, 2026
@MarkusNeusinger MarkusNeusinger merged commit ecf40c7 into main May 20, 2026
3 checks passed
@MarkusNeusinger MarkusNeusinger deleted the implementation/contour-map-geographic/seaborn branch May 20, 2026 23:05
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:83 Quality score 83/100

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant