Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 39 additions & 13 deletions plots/area-basic/implementations/matplotlib.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,64 @@
""" pyplots.ai
area-basic: Basic Area Chart
Library: matplotlib 3.10.8 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-23
Library: matplotlib 3.10.8 | Python 3.14.2
Quality: 95/100 | Created: 2025-12-23
"""

import matplotlib.colors as mcolors
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import PathPatch
from matplotlib.path import Path


# Data - daily website visitors over a month
# Data - daily website visitors over a month with weekend dips
np.random.seed(42)
days = np.arange(1, 31)
base_visitors = 5000 + np.linspace(0, 2000, 30) # Upward trend
noise = np.random.randn(30) * 500
visitors = base_visitors + noise
visitors = np.clip(visitors, 3000, 10000) # Realistic bounds
base_visitors = 5000 + np.linspace(0, 2500, 30) # Upward trend
weekend_effect = np.array([-1200 if d % 7 in (0, 6) else 0 for d in days]) # Weekend dips
noise = np.random.randn(30) * 400
visitors = base_visitors + weekend_effect + noise
visitors = np.clip(visitors, 2000, 10000)

# Create plot (4800x2700 px)
fig, ax = plt.subplots(figsize=(16, 9))

# Area chart with semi-transparent fill
ax.fill_between(days, visitors, alpha=0.4, color="#306998")
ax.plot(days, visitors, color="#306998", linewidth=3)
y_max = visitors.max() * 1.15

# Gradient fill using imshow clipped to the area shape
cmap = mcolors.LinearSegmentedColormap.from_list("area_grad", ["#d6e6f5", "#306998"])
gradient = np.linspace(0, 1, 256).reshape(-1, 1)
gradient = np.hstack([gradient, gradient])

# Build clip path manually from fill_between polygon
verts = [(days[0], 0)]
for d, v in zip(days, visitors, strict=True):
verts.append((d, v))
verts.append((days[-1], 0))
verts.append((days[0], 0))
codes = [Path.MOVETO] + [Path.LINETO] * (len(verts) - 2) + [Path.CLOSEPOLY]
clip_path = Path(verts, codes)

im = ax.imshow(
gradient, aspect="auto", cmap=cmap, alpha=0.6, extent=[days[0], days[-1], 0, y_max], origin="lower", zorder=1
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imshow call arguments are packed into a long single line, which makes it harder to scan and review (and may violate typical formatter line-length settings depending on project config). Consider formatting each keyword argument on its own line for readability.

Suggested change
gradient, aspect="auto", cmap=cmap, alpha=0.6, extent=[days[0], days[-1], 0, y_max], origin="lower", zorder=1
gradient,
aspect="auto",
cmap=cmap,
alpha=0.6,
extent=[days[0], days[-1], 0, y_max],
origin="lower",
zorder=1,

Copilot uses AI. Check for mistakes.
)
patch = PathPatch(clip_path, transform=ax.transData, facecolor="none", edgecolor="none")
ax.add_patch(patch)
im.set_clip_path(patch)

# Solid line on top
ax.plot(days, visitors, color="#306998", linewidth=3, zorder=3)

# Labels and styling
ax.set_xlabel("Day of Month", fontsize=20)
ax.set_ylabel("Daily Visitors", fontsize=20)
ax.set_ylabel("Daily Visitors (count)", fontsize=20)
ax.set_title("area-basic · matplotlib · pyplots.ai", fontsize=24)
ax.tick_params(axis="both", labelsize=16)
ax.grid(True, alpha=0.3, linestyle="--")

# Set axis limits for better presentation
# Set axis limits
ax.set_xlim(1, 30)
ax.set_ylim(0, ax.get_ylim()[1] * 1.1)
ax.set_ylim(0, y_max)

plt.tight_layout()
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
139 changes: 74 additions & 65 deletions plots/area-basic/metadata/matplotlib.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
library: matplotlib
specification_id: area-basic
created: '2025-12-23T00:46:12Z'
updated: '2025-12-23T00:49:27Z'
generated_by: claude-opus-4-5-20251101
updated: '2026-02-11T20:57:35Z'
generated_by: claude-opus-4-6
workflow_run: 20447957143
issue: 0
python_version: 3.13.11
python_version: 3.14.2
library_version: 3.10.8
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/matplotlib/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/matplotlib/plot_thumb.png
preview_html: null
quality_score: 92
quality_score: 95
impl_tags:
dependencies: []
techniques: []
techniques:
- patches
patterns:
- data-generation
- explicit-figure
- data-generation
- explicit-figure
dataprep: []
styling:
- alpha-blending
- grid-styling
- gradient-fill
- custom-colormap
- alpha-blending
- grid-styling
Comment on lines 14 to +26
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list items under techniques, patterns, and styling are indented at the same level as their keys, which makes the YAML invalid (the - ... entries won’t be parsed as values of those keys). Indent the list items beneath each key (e.g., techniques: then two additional spaces before - patches).

Copilot uses AI. Check for mistakes.
review:
strengths:
- 'Excellent adherence to spec requirements: semi-transparent fill, gridlines, clear
labels'
- Clean, readable code following KISS principles with proper random seed
- Perfect title format and appropriate font sizing throughout
- Realistic website visitor data with natural trend and variation
- Good use of fill_between with matching line plot on top
- Excellent gradient fill implementation using imshow clipped to the area polygon
— visually appealing and demonstrates advanced matplotlib techniques
- Data is well-crafted with realistic upward trend and periodic weekend dips that
showcase the area chart purpose
- Perfect text sizing following library guidelines (24pt title, 20pt labels, 16pt
ticks)
- Colorblind-safe blue palette (#306998) consistent with pyplots recommended colors
- Clean readable code with proper seed for reproducibility
weaknesses:
- Axis labels missing units (e.g., Daily Visitors could include count)
- Did not implement optional gradient fill from bottom to line for visual appeal
- Basic matplotlib usage without leveraging distinctive features
image_description: 'The plot displays a basic area chart with a blue filled area
(#306998 color) showing daily website visitors over a 30-day period. The x-axis
is labeled "Day of Month" ranging from 1 to 30, and the y-axis shows "Daily Visitors"
ranging from 0 to approximately 8000. The title follows the correct format: "area-basic
· matplotlib · pyplots.ai". The area is filled with semi-transparent blue (alpha
~0.4) with a solid blue line on top (linewidth 3). A subtle dashed grid (alpha
0.3) helps with value estimation. The data shows an upward trend with natural
variation - starting around 5000 visitors and trending upward to around 6500-7000
by day 30, with visible day-to-day fluctuations adding realism.'
- Y-axis starting at 0 with data in 4000-7500 range leaves significant empty space
at bottom, slightly reducing visual impact
- Data could include one more interesting feature such as a notable spike or event
for maximum feature coverage
image_description: The plot displays a basic area chart showing daily website visitors
over a 30-day month. The x-axis shows "Day of Month" (1–30), and the y-axis shows
"Daily Visitors (count)" (0–~8500). The area beneath the line is filled with a
vertical gradient transitioning from light blue (#d6e6f5) at the bottom to a deeper
blue (#306998) at the top, with alpha transparency of 0.6. The line itself is
a solid dark blue (#306998) at linewidth 3. The data shows a clear upward trend
from ~5000 visitors to ~7500 visitors, with periodic dips approximately every
7 days corresponding to weekends. Gridlines are subtle dashed lines at alpha 0.3.
The title reads "area-basic · matplotlib · pyplots.ai" in the correct format.
Layout is clean with balanced margins and good canvas utilization via tight_layout.
criteria_checklist:
visual_quality:
score: 37
Expand All @@ -52,43 +59,48 @@ review:
score: 10
max: 10
passed: true
comment: Title at 24pt, labels at 20pt, ticks at 16pt - all perfectly readable
comment: Title at 24pt, axis labels at 20pt, ticks at 16pt — all perfectly
readable at full size
- id: VQ-02
name: No Overlap
score: 8
max: 8
passed: true
comment: No overlapping elements anywhere
comment: No overlapping text elements anywhere
- id: VQ-03
name: Element Visibility
score: 8
max: 8
passed: true
comment: Line width of 3 is appropriate, area fill clearly visible
comment: Line at linewidth=3 is clearly visible, gradient fill with alpha=0.6
provides good visual weight
- id: VQ-04
name: Color Accessibility
score: 5
max: 5
passed: true
comment: Single blue color (#306998), good contrast, colorblind-safe
comment: Uses colorblind-safe blue palette (#306998), no problematic color
combinations
- id: VQ-05
name: Layout Balance
score: 5
score: 4
max: 5
passed: true
comment: Good proportions, tight_layout applied, no cut-off content
comment: Good canvas utilization with tight_layout; y-axis starting at 0 leaves
empty space below data range but appropriate for area charts
- id: VQ-06
name: Axis Labels
score: 1
score: 2
max: 2
passed: false
comment: Descriptive labels but missing units (e.g., "visitors/day")
passed: true
comment: 'Both axes have descriptive labels with units: Day of Month, Daily
Visitors (count)'
- id: VQ-07
name: Grid & Legend
score: 2
max: 2
passed: true
comment: Grid subtle at alpha 0.3 with dashed style, no legend needed
comment: Grid is subtle (alpha=0.3, dashed), no legend needed for single series
spec_compliance:
score: 25
max: 25
Expand All @@ -98,64 +110,62 @@ review:
score: 8
max: 8
passed: true
comment: Correct area chart with fill_between
comment: Correct area chart with filled region below line
- id: SC-02
name: Data Mapping
score: 5
max: 5
passed: true
comment: X=days, Y=visitors correctly assigned
comment: X is continuous (days), Y is numeric (visitors)
- id: SC-03
name: Required Features
score: 5
max: 5
passed: true
comment: Semi-transparent fill (alpha 0.4), gridlines present, clear axis
labels
comment: Semi-transparent fill, gridlines, clear axis labels with units, gradient
fill — all spec features present
- id: SC-04
name: Data Range
score: 3
max: 3
passed: true
comment: Y-axis starts at 0, X-axis shows full 1-30 range
comment: All data visible within axis limits
- id: SC-05
name: Legend Accuracy
score: 2
max: 2
passed: true
comment: No legend needed for single series (appropriate)
comment: Single series, no legend needed appropriate
- id: SC-06
name: Title Format
score: 2
max: 2
passed: true
comment: 'Uses exact format: "area-basic · matplotlib · pyplots.ai"'
comment: Exactly matches area-basic · matplotlib · pyplots.ai
data_quality:
score: 18
score: 19
max: 20
items:
- id: DQ-01
name: Feature Coverage
score: 7
max: 8
passed: true
comment: 'Shows upward trend with daily variation, demonstrates area chart
purpose well. Minor: could show more dramatic changes to emphasize "volume"
aspect'
comment: Shows upward trend and periodic weekend dips; could benefit from
one more feature like a sudden spike
- 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
matching spec examples
comment: Website daily visitors — realistic neutral scenario matching spec
example
- id: DQ-03
name: Appropriate Scale
score: 4
score: 5
max: 5
passed: true
comment: 5000-7000 visitors reasonable; baseline at 0 slightly exaggerates
visual weight but acceptable
comment: Values of 4000-7500 daily visitors are entirely realistic for a website
code_quality:
score: 10
max: 10
Expand All @@ -165,41 +175,40 @@ review:
score: 3
max: 3
passed: true
comment: 'Flat script: imports → data → plot → save'
comment: 'Clean linear flow: imports → data → plot → save'
- id: CQ-02
name: Reproducibility
score: 3
max: 3
passed: true
comment: np.random.seed(42) set
comment: Uses np.random.seed(42)
- id: CQ-03
name: Clean Imports
score: 2
max: 2
passed: true
comment: Only matplotlib.pyplot and numpy used
comment: All imports are used (mcolors, PathPatch, Path)
- id: CQ-04
name: No Deprecated API
score: 1
max: 1
passed: true
comment: All APIs current
comment: No deprecated functions used
- 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
library_features:
score: 2
score: 4
max: 5
items:
- id: LF-01
name: Uses distinctive library features
score: 2
name: Distinctive Features
score: 4
max: 5
passed: false
comment: Uses fill_between correctly but no gradient fill (mentioned in spec
notes as optional enhancement), no use of matplotlib-specific features like
color gradients or annotations
passed: true
comment: Uses imshow with custom clipping path for gradient fill, LinearSegmentedColormap,
and PathPatch — advanced matplotlib capabilities
verdict: APPROVED