diff --git a/plots/area-basic/implementations/seaborn.py b/plots/area-basic/implementations/seaborn.py index 8d4c20b579..7740c87305 100644 --- a/plots/area-basic/implementations/seaborn.py +++ b/plots/area-basic/implementations/seaborn.py @@ -1,7 +1,7 @@ """ pyplots.ai area-basic: Basic Area Chart -Library: seaborn 0.13.2 | Python 3.13.11 -Quality: 91/100 | Created: 2025-12-23 +Library: seaborn 0.13.2 | Python 3.14.2 +Quality: 98/100 | Created: 2025-12-23 """ import matplotlib.pyplot as plt @@ -14,34 +14,48 @@ np.random.seed(42) dates = pd.date_range(start="2024-01-01", periods=30, freq="D") -# Simulate realistic web traffic with weekly pattern and trend +# Simulate realistic web traffic with weekly pattern, trend, and a traffic spike base_visitors = 5000 trend = np.linspace(0, 1500, 30) weekly_pattern = np.array([1.0, 1.1, 1.15, 1.2, 1.1, 0.7, 0.65] * 5)[:30] noise = np.random.randn(30) * 300 visitors = (base_visitors + trend) * weekly_pattern + noise -visitors = np.maximum(visitors, 1000) # Ensure positive values +visitors[17] *= 1.45 # Traffic spike from a viral post on day 18 +visitors = np.maximum(visitors, 1000) df = pd.DataFrame({"date": dates, "visitors": visitors}) -# Plot +# Plot - seaborn styling and theme +sns.set_style("whitegrid", {"grid.linestyle": "--", "grid.alpha": 0.3}) +sns.set_context("talk", font_scale=1.1) + fig, ax = plt.subplots(figsize=(16, 9)) -# Area fill with semi-transparent Python Blue +# Area chart using seaborn lineplot with fill +sns.lineplot(data=df, x="date", y="visitors", ax=ax, color="#306998", linewidth=3, label="Daily visitors") ax.fill_between(df["date"], df["visitors"], alpha=0.4, color="#306998") -# Line on top using seaborn -sns.lineplot(data=df, x="date", y="visitors", ax=ax, color="#306998", linewidth=3) +# Annotate the traffic spike +spike_idx = 17 +ax.annotate( + "Viral post", + xy=(df["date"].iloc[spike_idx], df["visitors"].iloc[spike_idx]), + xytext=(df["date"].iloc[spike_idx - 6], df["visitors"].iloc[spike_idx] * 1.0), + fontsize=16, + color="#1a3a5c", + arrowprops={"arrowstyle": "->", "color": "#1a3a5c", "lw": 2}, + ha="center", +) # Style ax.set_xlabel("Date", fontsize=20) ax.set_ylabel("Visitors (count)", fontsize=20) ax.set_title("area-basic · seaborn · pyplots.ai", fontsize=24) ax.tick_params(axis="both", labelsize=16) -ax.grid(True, alpha=0.3, linestyle="--") +ax.legend(fontsize=16, loc="upper left", framealpha=0.9) -# Set y-axis to start at 0 to emphasize area magnitude -ax.set_ylim(bottom=0) +# Set y-axis to start at 0, cap top to reduce whitespace +ax.set_ylim(bottom=0, top=df["visitors"].max() * 1.12) # Format x-axis dates fig.autofmt_xdate(rotation=45) diff --git a/plots/area-basic/metadata/seaborn.yaml b/plots/area-basic/metadata/seaborn.yaml index 6312013886..191b1192e5 100644 --- a/plots/area-basic/metadata/seaborn.yaml +++ b/plots/area-basic/metadata/seaborn.yaml @@ -1,51 +1,55 @@ library: seaborn specification_id: area-basic created: '2025-12-23T00:47:02Z' -updated: '2025-12-23T00:51:01Z' -generated_by: claude-opus-4-5-20251101 +updated: '2026-02-11T22:26:29Z' +generated_by: claude-opus-4-6 workflow_run: 20447957405 issue: 0 -python_version: 3.13.11 +python_version: 3.14.2 library_version: 0.13.2 preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/seaborn/plot.png preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/seaborn/plot_thumb.png preview_html: null -quality_score: 91 +quality_score: 98 impl_tags: dependencies: [] - techniques: [] + techniques: + - annotations patterns: - - data-generation - - explicit-figure + - data-generation + - explicit-figure dataprep: - - time-series + - time-series styling: - - alpha-blending - - grid-styling + - alpha-blending + - grid-styling review: strengths: - - Excellent visual design with proper font sizes, color choices, and layout - - Realistic website traffic data with weekly patterns and upward trend effectively - demonstrates the area chart strength in showing magnitude over time - - Correct title format and axis labels with units - - Proper use of semi-transparent fill (alpha 0.4) as recommended in spec - - Y-axis starting at 0 correctly emphasizes the cumulative magnitude + - Excellent data generation with realistic weekly patterns, upward trend, and a + viral post spike — makes the area chart compelling and informative + - Clean annotation with arrow pointing to the traffic spike adds storytelling value + - Proper use of seaborn theming (whitegrid style, talk context) provides a polished, + professional look + - Semi-transparent fill at alpha 0.4 balances visual weight with readability + - Y-axis starting at 0 correctly emphasizes the volume aspect of the area chart weaknesses: - - The implementation uses matplotlib fill_between for the area rather than exploring - seaborn native capabilities (though seaborn lacks a dedicated area chart function) - - 'Grid legend scoring: single series plots could benefit from a subtle annotation - or data source note' - image_description: The plot displays a basic area chart showing website visitors - over time (January 2024). The chart uses a semi-transparent blue fill (#306998 - Python Blue at alpha 0.4) with a darker blue line (linewidth 3) on top. The x-axis - shows dates from 2024-01-01 to 2024-01-29 with rotated labels at 45 degrees. The - y-axis shows visitor counts from 0 to approximately 7500. The title "area-basic - · seaborn · pyplots.ai" appears at the top. A clear weekly pattern is visible - with dips on weekends (lower traffic) and peaks mid-week. There's also an overall - upward trend. The gridlines are subtle with alpha 0.3 and dashed style. + - The fill_between call is pure matplotlib rather than a seaborn-native feature + — though this is unavoidable since seaborn lacks a dedicated area chart function + image_description: The plot displays a basic area chart showing daily website visitors + over January 2024 (30 days). A single blue (#306998) line traces the visitor count + with the area below filled in a semi-transparent blue (alpha ~0.4). The y-axis + starts at 0 and extends to approximately 11,200 with label "Visitors (count)". + The x-axis shows dates from 2024-01-01 to 2024-01-30, with labels rotated 45° + for readability. A clear weekly cyclic pattern is visible — peaks mid-week around + 6,000-7,000 and dips on weekends to ~3,500-4,000. An upward trend is apparent + over the month. A notable traffic spike around January 18 reaches ~10,300 visitors, + annotated with "Viral post" and an arrow pointing to the peak. The background + uses a whitegrid style with dashed gridlines at low opacity. A legend in the upper + left shows "Daily visitors". The title reads "area-basic · seaborn · pyplots.ai" + in the correct format. criteria_checklist: visual_quality: - score: 37 + score: 40 max: 40 items: - id: VQ-01 @@ -53,46 +57,48 @@ review: score: 10 max: 10 passed: true - comment: Title at fontsize 24, axis labels at 20, tick labels at 16, all perfectly - readable + comment: Title 24pt, labels 20pt, ticks 16pt — all perfectly readable at full + resolution - id: VQ-02 name: No Overlap score: 8 max: 8 passed: true - comment: No overlapping text, date labels are rotated to avoid collision + comment: Date labels rotated 45°, annotation clear of other elements, legend + in upper left - id: VQ-03 name: Element Visibility score: 8 max: 8 passed: true - comment: Line width of 3 is optimal, area fill at alpha 0.4 shows magnitude - clearly + comment: Line width 3 appropriate for 30 data points, fill alpha 0.4 gives + good visual weight - id: VQ-04 name: Color Accessibility score: 5 max: 5 passed: true - comment: Single color scheme (Python Blue), colorblind-safe + comment: Single blue color series, no colorblind concerns - id: VQ-05 name: Layout Balance - score: 4 + score: 5 max: 5 passed: true - comment: Good proportions, slight excess whitespace at top + comment: Plot fills canvas well, balanced margins, y-axis starting at 0 gives + proper area emphasis - id: VQ-06 name: Axis Labels score: 2 max: 2 passed: true - comment: '"Date" and "Visitors (count)" - descriptive with units' + comment: Date and Visitors (count) — descriptive with units - id: VQ-07 name: Grid & Legend - score: 0 + score: 2 max: 2 passed: true - comment: Grid is good (alpha 0.3), but no legend present (single series, acceptable - but not ideal) + comment: Dashed grid at alpha 0.3 is subtle, legend well-placed with framealpha + 0.9 spec_compliance: score: 25 max: 25 @@ -108,58 +114,59 @@ review: score: 5 max: 5 passed: true - comment: X=datetime (dates), Y=numeric (visitors) correctly assigned + comment: X = dates (continuous time), Y = visitors (numeric magnitude) - id: SC-03 name: Required Features score: 5 max: 5 passed: true - comment: Semi-transparent fill (alpha 0.4), gridlines, clear axis labels all - present + comment: Semi-transparent fill (alpha 0.4), gridlines present, clear axis + labels with units - id: SC-04 name: Data Range score: 3 max: 3 passed: true - comment: Y-axis starts at 0 (emphasizes area magnitude), all data visible + comment: Y starts at 0, all 30 data points visible within axes - id: SC-05 name: Legend Accuracy score: 2 max: 2 passed: true - comment: Single series, no legend needed + comment: Daily visitors matches data correctly - id: SC-06 name: Title Format score: 2 max: 2 passed: true - comment: Uses correct format "area-basic · seaborn · pyplots.ai" + comment: area-basic · seaborn · pyplots.ai in correct format data_quality: - score: 17 + score: 20 max: 20 items: - id: DQ-01 name: Feature Coverage - score: 6 + score: 8 max: 8 passed: true - comment: Shows weekly pattern and upward trend, demonstrates magnitude emphasis - well, but could show more variety (e.g., occasional anomalies) + comment: Shows upward trend, weekly cyclic pattern, traffic spike, noise — + demonstrates area chart volume emphasis - id: DQ-02 name: Realistic Context score: 7 max: 7 passed: true - comment: Daily website visitors over a month is a perfect real-world scenario + comment: Website traffic with realistic weekly patterns (weekend dips), neutral + topic - id: DQ-03 name: Appropriate Scale - score: 4 + score: 5 max: 5 passed: true - comment: Values 3000-7500 are realistic for website traffic, though starting - y at 0 adds some empty space + comment: 3,000–10,000 daily visitors plausible for mid-sized site, 1.45x spike + realistic code_quality: - score: 9 + score: 10 max: 10 items: - id: CQ-01 @@ -167,43 +174,41 @@ review: score: 3 max: 3 passed: true - comment: Clean imports → data → plot → save structure, no functions/classes + comment: Clean Imports → Data → Plot → Save flow, no functions/classes - id: CQ-02 name: Reproducibility score: 3 max: 3 passed: true - comment: Uses np.random.seed(42) + comment: np.random.seed(42) set - id: CQ-03 name: Clean Imports score: 2 max: 2 passed: true - comment: All imports are used (matplotlib, numpy, pandas, seaborn) + comment: All four imports (matplotlib, numpy, pandas, seaborn) are used - id: CQ-04 name: No Deprecated API - score: 0 + score: 1 max: 1 passed: true - comment: 'Minor: Uses ax.fill_between from matplotlib instead of seaborn-native - approach' + comment: No deprecated functions - id: CQ-05 name: Output Correct score: 1 max: 1 passed: true - comment: Saves as plot.png with dpi=300 + comment: Saves as plot.png at dpi=300 library_features: score: 3 max: 5 items: - id: LF-01 - name: Uses distinctive library features + name: Distinctive Features score: 3 max: 5 passed: true - comment: Uses sns.lineplot which is seaborn-native, but the area fill uses - matplotlib's ax.fill_between. Seaborn doesn't have a native area chart function, - so this hybrid approach is acceptable but doesn't showcase seaborn's distinctive - features like regplot, kdeplot, or statistical aggregation. + comment: Good use of sns.set_style, sns.set_context, and sns.lineplot. Area + fill uses matplotlib fill_between since seaborn lacks native area chart + function. verdict: APPROVED