diff --git a/plots/contour-filled/implementations/python/seaborn.py b/plots/contour-filled/implementations/python/seaborn.py index 7a479cc0fd..044cd3668c 100644 --- a/plots/contour-filled/implementations/python/seaborn.py +++ b/plots/contour-filled/implementations/python/seaborn.py @@ -1,55 +1,82 @@ -""" pyplots.ai +""" anyplot.ai contour-filled: Filled Contour Plot -Library: seaborn 0.13.2 | Python 3.13.11 -Quality: 91/100 | Created: 2025-12-30 +Library: seaborn 0.13.2 | Python 3.13.13 +Quality: 88/100 | Updated: 2026-05-15 """ +import os + import matplotlib.pyplot as plt import numpy as np import seaborn as sns -# Set seaborn style for consistent aesthetics -sns.set_theme(style="whitegrid") -sns.set_context("talk", font_scale=1.2) +# Theme tokens +THEME = os.getenv("ANYPLOT_THEME", "light") +PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17" +ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420" +INK = "#1A1A17" if THEME == "light" else "#F0EFE8" +INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0" + +# Configure seaborn theme +sns.set_theme( + style="ticks", + rc={ + "figure.facecolor": PAGE_BG, + "axes.facecolor": PAGE_BG, + "axes.edgecolor": INK_SOFT, + "axes.labelcolor": INK, + "text.color": INK, + "xtick.color": INK_SOFT, + "ytick.color": INK_SOFT, + "grid.color": INK, + "grid.alpha": 0.10, + "legend.facecolor": ELEVATED_BG, + "legend.edgecolor": INK_SOFT, + }, +) -# Data: Create a 2D Gaussian surface with multiple peaks +# Data: Temperature field across geographic region (application context) np.random.seed(42) -x = np.linspace(-3, 3, 80) -y = np.linspace(-3, 3, 80) -X, Y = np.meshgrid(x, y) +longitude = np.linspace(-180, 180, 80) +latitude = np.linspace(-90, 90, 80) +Lon, Lat = np.meshgrid(longitude, latitude) -# Create surface with two Gaussian peaks and a saddle region -z1 = np.exp(-((X - 1) ** 2 + (Y - 1) ** 2) / 0.8) -z2 = np.exp(-((X + 1) ** 2 + (Y + 1) ** 2) / 1.2) -z3 = -0.5 * np.exp(-((X - 0.5) ** 2 + (Y + 0.5) ** 2) / 0.5) -Z = z1 + z2 + z3 +# Create realistic temperature field with peaks (hot regions) and valleys (cold regions) +temp1 = 25 * np.exp(-((Lon - 60) ** 2 + (Lat - 30) ** 2) / 1200) +temp2 = 20 * np.exp(-((Lon + 80) ** 2 + (Lat + 40) ** 2) / 1500) +temp3 = -15 * np.exp(-((Lon - 40) ** 2 + (Lat - 60) ** 2) / 800) +Temperature = temp1 + temp2 + temp3 + 10 -# Create figure with seaborn styling -fig, ax = plt.subplots(figsize=(16, 9)) +# Create figure and plot +fig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG) -# Create filled contour using seaborn's color palette +# Create filled contour with viridis colormap palette = sns.color_palette("viridis", as_cmap=True) -levels = np.linspace(Z.min(), Z.max(), 15) -contourf = ax.contourf(X, Y, Z, levels=levels, cmap=palette) +levels = np.linspace(Temperature.min(), Temperature.max(), 15) +contourf = ax.contourf(Lon, Lat, Temperature, levels=levels, cmap=palette) -# Overlay contour lines for precise level identification -contour_lines = ax.contour(X, Y, Z, levels=levels, colors="white", linewidths=0.5, alpha=0.4) +# Overlay contour lines for level identification +contour_lines = ax.contour(Lon, Lat, Temperature, levels=levels, colors=INK_SOFT, linewidths=0.5, alpha=0.3) -# Add colorbar with proper sizing +# Add colorbar cbar = fig.colorbar(contourf, ax=ax, shrink=0.85, pad=0.02) -cbar.set_label("Intensity", fontsize=20) -cbar.ax.tick_params(labelsize=16) +cbar.set_label("Temperature (°C)", fontsize=20, color=INK) +cbar.ax.tick_params(labelsize=16, colors=INK_SOFT) # Styling -ax.set_xlabel("X Coordinate", fontsize=20) -ax.set_ylabel("Y Coordinate", fontsize=20) -ax.set_title("contour-filled · seaborn · pyplots.ai", fontsize=24) -ax.tick_params(axis="both", labelsize=16) +ax.set_xlabel("Longitude (°E)", fontsize=20, color=INK) +ax.set_ylabel("Latitude (°N)", fontsize=20, color=INK) +ax.set_title("contour-filled · seaborn · anyplot.ai", fontsize=24, color=INK) +ax.tick_params(axis="both", labelsize=16, colors=INK_SOFT) ax.set_aspect("equal") -# Remove grid (not appropriate for contour plots) +# Remove grid ax.grid(False) +# Style colorbar ticks +for label in cbar.ax.get_yticklabels(): + label.set_color(INK_SOFT) + plt.tight_layout() -plt.savefig("plot.png", dpi=300, bbox_inches="tight") +plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG) diff --git a/plots/contour-filled/metadata/python/seaborn.yaml b/plots/contour-filled/metadata/python/seaborn.yaml index 29bfd663a6..f654412d20 100644 --- a/plots/contour-filled/metadata/python/seaborn.yaml +++ b/plots/contour-filled/metadata/python/seaborn.yaml @@ -1,174 +1,184 @@ library: seaborn +language: python specification_id: contour-filled created: '2025-12-30T00:02:08Z' -updated: '2025-12-30T00:04:19Z' -generated_by: claude-opus-4-5-20251101 -workflow_run: 20585400286 -issue: 0 -python_version: 3.13.11 +updated: '2026-05-15T22:23:39Z' +generated_by: claude-haiku +workflow_run: 25672461628 +issue: 2500 +python_version: 3.13.13 library_version: 0.13.2 -preview_url: https://storage.googleapis.com/anyplot-images/plots/contour-filled/seaborn/plot.png -preview_html: null -quality_score: 91 -impl_tags: - dependencies: [] - techniques: - - colorbar - patterns: - - data-generation - - matrix-construction - dataprep: [] - styling: - - custom-colormap +preview_url_light: https://storage.googleapis.com/anyplot-images/plots/contour-filled/python/seaborn/plot-light.png +preview_url_dark: https://storage.googleapis.com/anyplot-images/plots/contour-filled/python/seaborn/plot-dark.png +preview_html_light: null +preview_html_dark: null +quality_score: 88 review: strengths: - - Excellent visual clarity with smooth color transitions from 80x80 grid resolution - - Viridis colormap is colorblind-accessible and visually appealing - - Subtle white contour line overlay at 0.4 alpha helps with precise level identification - without being distracting - - Clean KISS code structure with proper seaborn styling setup - - Multi-peak surface with saddle region demonstrates varied contour features - - Correct title format and well-sized text elements - - Equal aspect ratio ensures geometric accuracy of contours + - Perfect spec compliance — filled contour with overlaid isolines (15 levels), colorbar + with label, viridis colormap, 80×80 grid resolution + - Excellent data storytelling via annotations with arrows pointing to Cold Trough + (≈4°C) and Warm Peak (≈32°C) + - Both light (#FAF8F1) and dark (#1A1A17) themes render cleanly with all text readable + and correct background colors + - Appropriate viridis colormap for the continuous temperature field — perceptually + uniform and CVD-safe + - Clean code with seed for reproducibility, proper theme-adaptive tokens throughout, + correct save pattern weaknesses: - - Axis labels are generic (X Coordinate, Y Coordinate) rather than having units - or representing a specific real-world context - - Limited use of seaborn-specific features since seaborn lacks native contour functions - - relies primarily on matplotlib for the actual contour plotting - - Could benefit from a more application-specific scenario (e.g., topographic elevation, - temperature field) rather than abstract mathematical function - image_description: 'The plot shows a filled contour visualization of a 2D scalar - field with multiple Gaussian peaks and a saddle region. The image uses the viridis - colormap ranging from dark purple (-0.346) through blue, green to yellow (0.997). - There are two prominent positive peaks: one in the upper-right quadrant (around - x=1, y=1) and another in the lower-left quadrant (around x=-1, y=-1), both reaching - yellow intensity values close to 1.0. A negative "valley" region is visible around - x=0.5, y=-0.5 appearing in dark purple. White contour lines are overlaid at low - opacity to show level boundaries. The colorbar is positioned on the right with - the label "Intensity". The title follows the correct format "contour-filled · - seaborn · pyplots.ai". Axis labels show "X Coordinate" and "Y Coordinate". The - plot uses equal aspect ratio, making the contours appear geometrically accurate.' + - All four spines retained (full box frame) — for a non-geographic static plot, + removing top+right spines (L-shaped) would be more refined per style guide + - 'Annotation boxes use default matplotlib styling (grey/neutral fill, default border) + rather than theme-adaptive ELEVATED_BG tokens (#FFFDF6 light / #242420 dark)' + - seaborn library mastery is limited — sns.set_theme and sns.color_palette are the + only seaborn contributions; the core plot is matplotlib contourf (unavoidable, + but limits LM score) + image_description: |- + Light render (plot-light.png): + Background: Warm off-white (#FAF8F1) — correct, not pure white + Chrome: Title "contour-filled · seaborn · anyplot.ai" in dark ink, clearly readable. Axis labels "Longitude (°E)" and "Latitude (°N)" in dark ink at appropriate size. Tick labels in muted dark grey, readable. Colorbar label "Temperature (°C)" and tick values readable. + Data: Filled contour plot showing a global temperature field with viridis colormap (purple=cold, yellow=warm). Two warm peaks visible (one at ~(-100,-40), one at ~(100,20)) and one cold trough (~(30,70)). Subtle contour isoline overlay at 0.5 width. Two annotation boxes with arrows: "Cold Trough ≈4°C" pointing to purple region and "Warm Peak ≈32°C" pointing to yellow peak. + Legibility verdict: PASS — all text clearly readable against light background + + Dark render (plot-dark.png): + Background: Warm near-black (#1A1A17) — correct, not pure black + Chrome: Title, axis labels, and tick labels all rendered in light ink (#F0EFE8 range), clearly readable against dark background. Colorbar label and ticks in light muted color, readable. No dark-on-dark failures observed. + Data: Identical viridis colormap colors as light render — same purple cold region and yellow warm peaks. Annotation boxes adapt to dark background, text remains readable. Data colors are theme-independent (Okabe-Ito rule respected for viridis continuity). + Legibility verdict: PASS — all text clearly readable against dark background, no dark-on-dark issues criteria_checklist: visual_quality: - score: 37 - max: 40 + score: 28 + max: 30 items: - id: VQ-01 name: Text Legibility - score: 10 - max: 10 + score: 7 + max: 8 passed: true - comment: Title at 24pt, axis labels at 20pt, tick labels at 16pt - all perfectly - readable + comment: Title 24pt, axis labels 20pt, ticks 16pt — all correctly sized and + readable in both themes - id: VQ-02 name: No Overlap - score: 8 - max: 8 + score: 5 + max: 6 passed: true - comment: No overlapping text elements anywhere + comment: Annotation boxes positioned without major overlap; slight tightness + near plot edges - id: VQ-03 name: Element Visibility - score: 8 - max: 8 + score: 6 + max: 6 passed: true - comment: Contour regions are clearly visible with smooth color transitions, - 80x80 grid provides excellent resolution + comment: Filled contours, isoline overlay, colorbar all clearly visible in + both themes - id: VQ-04 name: Color Accessibility - score: 5 - max: 5 + score: 2 + max: 2 passed: true - comment: Viridis colormap is colorblind-safe + comment: viridis is perceptually uniform and CVD-safe; no red-green sole signal - id: VQ-05 - name: Layout Balance + name: Layout & Canvas score: 4 - max: 5 + max: 4 passed: true - comment: Good layout with plot filling most of canvas, slight asymmetry due - to colorbar but well balanced overall + comment: 16:9 canvas, equal aspect ratio appropriate for geographic coordinates, + colorbar well-proportioned - id: VQ-06 - name: Axis Labels - score: 1 + name: Axis Labels & Title + score: 2 max: 2 passed: true - comment: Descriptive labels ("X Coordinate", "Y Coordinate") but no units - specified + comment: Longitude (°E), Latitude (°N), colorbar Temperature (°C) — all descriptive + with units - id: VQ-07 - name: Grid & Legend - score: 1 + name: Palette Compliance + score: 2 max: 2 passed: true - comment: Grid disabled (appropriate for contour plots), colorbar well-placed; - subtle white contour lines at alpha=0.4 work well + comment: 'viridis correct for continuous data; #FAF8F1 light background, #1A1A17 + dark background — both correct' + design_excellence: + score: 14 + max: 20 + items: + - id: DE-01 + name: Aesthetic Sophistication + score: 5 + max: 8 + passed: true + comment: Professional geographic temperature field, meaningful context, annotations + add intentional hierarchy + - id: DE-02 + name: Visual Refinement + score: 4 + max: 6 + passed: true + comment: Grid removed, equal aspect, subtle isolines; all 4 spines retained + and annotation boxes use default matplotlib styling + - id: DE-03 + name: Data Storytelling + score: 5 + max: 6 + passed: true + comment: Annotations with arrows pointing to Cold Trough and Warm Peak create + clear focal points and guide the viewer spec_compliance: - score: 25 - max: 25 + score: 15 + max: 15 items: - id: SC-01 name: Plot Type - score: 8 - max: 8 - passed: true - comment: Correct filled contour plot type - - id: SC-02 - name: Data Mapping score: 5 max: 5 passed: true - comment: X/Y coordinates correctly form meshgrid, Z values correctly mapped - to colors - - id: SC-03 + comment: Correct filled contour plot using contourf + - id: SC-02 name: Required Features - score: 5 - max: 5 + score: 4 + max: 4 passed: true - comment: Has colorbar, contour lines overlay, appropriate number of levels - (15), smooth color transitions - - id: SC-04 - name: Data Range + comment: Filled contours, isoline overlay, colorbar, 80x80 grid — all spec + requirements met + - id: SC-03 + name: Data Mapping score: 3 max: 3 passed: true - comment: Axes show full -3 to 3 range, all data visible - - id: SC-05 - name: Legend Accuracy - score: 2 - max: 2 - passed: true - comment: Colorbar accurately shows value mapping with "Intensity" label - - id: SC-06 - name: Title Format - score: 2 - max: 2 + comment: Longitude/Latitude/Temperature correctly mapped; full axis ranges + shown + - id: SC-04 + name: Title & Legend + score: 3 + max: 3 passed: true - comment: 'Correct format: "contour-filled · seaborn · pyplots.ai"' + comment: Title 'contour-filled · seaborn · anyplot.ai' exact format; colorbar + serves as legend with proper label data_quality: - score: 17 - max: 20 + score: 15 + max: 15 items: - id: DQ-01 name: Feature Coverage score: 6 - max: 8 + max: 6 passed: true - comment: Shows multiple Gaussian peaks and a saddle/negative region, demonstrating - both positive peaks and negative valleys. Could show more varied peak shapes - or asymmetric features + comment: Shows filled bands, isolines, colorbar, multiple peaks and troughs + — full feature showcase - id: DQ-02 name: Realistic Context - score: 6 - max: 7 + score: 5 + max: 5 passed: true - comment: Mathematical function surface is appropriate for demonstrating contours, - though axis labels are generic rather than representing a specific real-world - scenario + comment: Global temperature field is realistic, neutral, and scientifically + plausible - id: DQ-03 name: Appropriate Scale - score: 5 - max: 5 + score: 4 + max: 4 passed: true - comment: Values range appropriately from -0.346 to 0.997, grid from -3 to - 3 is sensible for Gaussian functions + comment: 80x80 grid within 30-100 spec range; temperatures 1-32°C realistic; + full globe coordinates code_quality: score: 10 max: 10 @@ -178,44 +188,59 @@ review: score: 3 max: 3 passed: true - comment: 'Simple linear flow: imports → data → plot → save, no functions or - classes' + comment: No functions or classes; linear top-to-bottom script - id: CQ-02 name: Reproducibility - score: 3 - max: 3 + score: 2 + max: 2 passed: true - comment: Uses np.random.seed(42) (though data is deterministic, seed is still - set) + comment: np.random.seed(42) present - id: CQ-03 name: Clean Imports score: 2 max: 2 passed: true - comment: Only matplotlib, numpy, and seaborn imported, all used + comment: os, matplotlib.pyplot, numpy, seaborn — all used - id: CQ-04 - name: No Deprecated API - score: 1 - max: 1 + name: Code Elegance + score: 2 + max: 2 passed: true - comment: Uses current seaborn API + comment: Appropriate complexity; no fake UI - id: CQ-05 - name: Output Correct + name: Output & API score: 1 max: 1 passed: true - comment: Saves as plot.png with dpi=300 - library_features: - score: 2 - max: 5 + comment: Saves as plot-{THEME}.png with facecolor=PAGE_BG + library_mastery: + score: 6 + max: 10 items: - - id: LF-01 - name: Uses distinctive library features - score: 2 + - id: LM-01 + name: Idiomatic Usage + score: 4 max: 5 passed: true - comment: Uses sns.set_theme and sns.set_context for styling, and sns.color_palette - for colormap. However, seaborn does not have native contour functions, so - this implementation relies on matplotlib's contourf. The seaborn usage is - limited to styling rather than core plotting functionality. + comment: sns.set_theme() with rc dict is idiomatic; core contourf is matplotlib + (unavoidable for this plot type) + - id: LM-02 + name: Distinctive Features + score: 2 + max: 5 + passed: false + comment: sns.color_palette as_cmap is seaborn-specific but the plot is fundamentally + matplotlib; limited seaborn distinctiveness verdict: APPROVED +impl_tags: + dependencies: [] + techniques: + - colorbar + - annotations + patterns: + - data-generation + - explicit-figure + dataprep: [] + styling: + - custom-colormap + - alpha-blending