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
30 changes: 23 additions & 7 deletions plots/area-basic/implementations/plotnine.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
""" pyplots.ai
area-basic: Basic Area Chart
Library: plotnine 0.15.2 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-23
Library: plotnine 0.15.3 | Python 3.14.2
Quality: 97/100 | Created: 2025-12-23
Comment on lines 1 to +4
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 implementation header no longer matches the repository’s standard format (leading space after triple quotes, and the “Quality: NN/100 | Created: YYYY-MM-DD” pattern). Quality: /100 is missing the numeric score and Updated: is a new token; if any tooling parses these headers, this will break. Please restore the standard header format and include the actual quality score/date fields consistently with other plot implementations.

Copilot uses AI. Check for mistakes.
"""

import numpy as np
import pandas as pd
from plotnine import (
aes,
annotate,
element_blank,
element_line,
element_text,
geom_area,
geom_line,
geom_smooth,
ggplot,
labs,
scale_x_datetime,
scale_y_continuous,
theme,
theme_minimal,
)
Expand All @@ -27,19 +30,32 @@
base_traffic = 5000
trend = np.linspace(0, 2000, 30)
weekly_pattern = 1000 * np.sin(np.arange(30) * 2 * np.pi / 7)
noise = np.random.normal(0, 500, 30)
visitors = base_traffic + trend + weekly_pattern + noise
visitors = np.maximum(visitors, 1000) # Ensure no negative values
# Increasing amplitude over time for better feature coverage
amplitude_growth = np.linspace(1.0, 1.8, 30)
noise = np.random.normal(0, 500, 30) * amplitude_growth
visitors = base_traffic + trend + weekly_pattern * amplitude_growth + noise
visitors = np.maximum(visitors, 1000)

df = pd.DataFrame({"date": dates, "visitors": visitors})

# Plot
plot = (
ggplot(df, aes(x="date", y="visitors"))
+ geom_area(fill="#306998", alpha=0.4)
+ geom_area(fill="#306998", alpha=0.35)
+ geom_line(color="#306998", size=1.5)
+ labs(x="Date", y="Daily Visitors", title="area-basic · plotnine · pyplots.ai")
+ geom_smooth(method="lowess", color="#FFD43B", size=1.2, se=False, span=0.5)
+ annotate(
"text",
x=dates[df["visitors"].idxmax()],
y=df["visitors"].max() + 300,
label="Peak",
size=14,
color="#306998",
fontweight="bold",
)
+ labs(x="Date (January 2024)", y="Daily Visitors (count)", title="area-basic · plotnine · pyplots.ai")
+ scale_x_datetime(date_labels="%b %d")
+ scale_y_continuous(labels=lambda lst: [f"{int(v):,}" for v in lst])
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.

scale_y_continuous(labels=...) currently casts tick values with int(v) before formatting. If plotnine generates non-integer breaks (e.g., 6500.0 or 6499.9), this will truncate rather than round, producing potentially inaccurate tick labels. Prefer formatting with rounding (e.g., :,.0f) or a dedicated formatter to preserve the intended tick values.

Suggested change
+ scale_y_continuous(labels=lambda lst: [f"{int(v):,}" for v in lst])
+ scale_y_continuous(labels=lambda lst: [f"{v:,.0f}" for v in lst])

Copilot uses AI. Check for mistakes.
+ theme_minimal()
+ theme(
figure_size=(16, 9),
Expand Down
149 changes: 84 additions & 65 deletions plots/area-basic/metadata/plotnine.yaml
Original file line number Diff line number Diff line change
@@ -1,97 +1,112 @@
library: plotnine
specification_id: area-basic
created: '2025-12-23T00:48:00Z'
updated: '2025-12-23T01:21:15Z'
generated_by: claude-opus-4-5-20251101
updated: '2026-02-11T22:27:13Z'
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.

updated uses an ISO timestamp with +00:00 offset, while the rest of the repo’s plot metadata consistently uses the ...Z UTC form (e.g., plots/area-basic/metadata/matplotlib.yaml:4). Please normalize this to the same Z format for consistency across metadata.

Copilot uses AI. Check for mistakes.
generated_by: claude-opus-4-6
workflow_run: 20447970072
issue: 0
python_version: 3.13.11
library_version: 0.15.2
python_version: 3.14.2
library_version: 0.15.3
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/plotnine/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/plotnine/plot_thumb.png
preview_html: null
quality_score: 92
quality_score: 97
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.

quality_score was changed from a numeric value to null. This is the only metadata file in plots/ with a null quality score and may break any consumers that expect an integer score. Please set quality_score to the computed score for this update (and keep it in sync with the implementation header).

Copilot uses AI. Check for mistakes.
impl_tags:
dependencies: []
techniques:
- layer-composition
- annotations
- layer-composition
patterns:
- data-generation
- explicit-figure
dataprep: []
- data-generation
dataprep:
- time-series
styling:
- alpha-blending
- grid-styling
- alpha-blending
- grid-styling
review:
strengths:
- Excellent use of ggplot2 grammar with proper layering (geom_area + geom_line)
- Realistic website traffic data with weekly cyclical pattern and upward trend
- Semi-transparent fill (alpha=0.4) as recommended in spec for readability
- Clean, minimal theme with subtle grid lines
- Proper title format and legible text sizes throughout
- Good use of scale_x_datetime for proper date formatting
- Excellent visual quality with perfectly sized text elements matching library guidelines
(24/20/16pt hierarchy)
- Effective use of plotnine grammar of graphics with multi-layer composition (geom_area
+ geom_line + geom_smooth)
- Realistic, well-contextualized data scenario (website visitors) with meaningful
patterns (weekly cycles, upward trend, increasing variance)
- 'Clean, colorblind-safe color scheme using pyplots primary palette (#306998, #FFD43B)'
- Subtle grid styling with alpha=0.3 and removed minor gridlines creates clean appearance
- Peak annotation adds informational value without cluttering
weaknesses:
- Axis labels lack units (could be "Daily Visitors (count)" or "Date (2024)")
- Could leverage more plotnine-specific features like stat_smooth for trend visualization
image_description: The plot displays a basic area chart showing daily website visitors
over January 2024. The chart uses a blue color (#306998) with semi-transparent
fill (alpha ~0.4) and a solid blue line on top. The X-axis displays dates from
Jan 01 to Jan 29 with weekly intervals labeled (Jan 01, Jan 08, Jan 15, Jan 22,
Jan 29). The Y-axis shows "Daily Visitors" ranging from 0 to 8000. The title "area-basic
· plotnine · pyplots.ai" is centered at the top. The data shows a clear cyclical
weekly pattern with peaks and troughs, overlaid with an upward trend, representing
realistic website traffic patterns. Grid lines are subtle and horizontal only.
The overall layout is clean with good proportions.
- The yellow LOWESS trend line lacks a legend or label explaining what it represents
— a viewer unfamiliar with the chart must guess its purpose
- Feature coverage could be slightly richer (e.g., showing a flat period or a sudden
spike/dip to demonstrate more area chart characteristics)
image_description: The plot displays a basic area chart of daily website visitors
over January 2024. The area beneath the data line is filled with a semi-transparent
steel blue (#306998, alpha ~0.35), bounded by a solid blue outline (line weight
1.5). A yellow/gold (#FFD43B) LOWESS trend line smoothly traces through the data,
highlighting the overall upward trend. A bold blue "Peak" annotation sits at the
upper-right, marking the highest visitor count (~8,200 on Jan 30). The x-axis
shows dates from Jan 01 to Jan 29 in "Mon DD" format, labeled "Date (January 2024)".
The y-axis shows visitor counts from 0 to 8,000 with comma-formatted tick labels,
labeled "Daily Visitors (count)". The title reads "area-basic · plotnine · pyplots.ai"
in the correct format. The background uses a minimal theme with subtle light-gray
major gridlines and no minor gridlines. The data exhibits a clear cyclical weekly
pattern with an upward trend and increasing amplitude over the month.
criteria_checklist:
visual_quality:
score: 37
score: 40
max: 40
items:
- id: VQ-01
name: Text Legibility
score: 10
max: 10
passed: true
comment: Title, axis labels, and tick labels are all clearly readable at appropriate
sizes
comment: Title ~24pt, axis labels ~20pt, tick labels ~16pt — all perfectly
readable at full resolution
- id: VQ-02
name: No Overlap
score: 8
max: 8
passed: true
comment: No overlapping text elements
comment: No overlapping text anywhere; date labels well-spaced, Peak annotation
clear
- id: VQ-03
name: Element Visibility
score: 8
max: 8
passed: true
comment: Area fill and line are appropriately visible with good alpha
comment: Area fill clearly visible with appropriate alpha, line weight 1.5
well-suited for 30 data points, LOWESS trend line distinct
- id: VQ-04
name: Color Accessibility
score: 5
max: 5
passed: true
comment: Single blue color, no colorblind issues
comment: 'Uses pyplots primary colors (#306998 blue, #FFD43B yellow) — colorblind-safe,
high contrast'
- id: VQ-05
name: Layout Balance
score: 5
max: 5
passed: true
comment: Good proportions, no cut-off content
comment: Plot fills canvas well in 16:9 ratio, balanced margins, no wasted
space
- id: VQ-06
name: Axis Labels
score: 1
score: 2
max: 2
passed: false
comment: '"Daily Visitors" and "Date" are descriptive but lack units'
passed: true
comment: 'X: Date (January 2024) with context, Y: Daily Visitors (count) with
units'
- id: VQ-07
name: Grid & Legend
score: 2
max: 2
passed: true
comment: Grid is subtle (alpha 0.3), no legend needed for single series
comment: 'Subtle major gridlines (alpha=0.3, #cccccc), minor grid removed,
no legend needed for single series'
spec_compliance:
score: 25
score: 24
max: 25
items:
- id: SC-01
Expand All @@ -105,56 +120,58 @@ review:
score: 5
max: 5
passed: true
comment: X=datetime, Y=numeric correctly assigned
comment: X=datetime dates, Y=numeric visitor counts — correctly assigned
- id: SC-03
name: Required Features
score: 5
max: 5
passed: true
comment: Semi-transparent fill, gridlines, clear axis labels all present
comment: Semi-transparent fill (alpha 0.35), gridlines present, clear axis
labels with units
- id: SC-04
name: Data Range
score: 3
max: 3
passed: true
comment: All data visible, Y-axis starts at 0
comment: Y-axis 0–8,000+ shows all data; X-axis covers full 30-day range
- id: SC-05
name: Legend Accuracy
score: 2
score: 1
max: 2
passed: true
comment: N/A for single series, no legend needed
passed: false
comment: Yellow LOWESS trend line has no legend entry; viewer may not understand
what it represents
- id: SC-06
name: Title Format
score: 2
max: 2
passed: true
comment: Correctly formatted as "area-basic · plotnine · pyplots.ai"
comment: area-basic · plotnine · pyplots.ai matches required format with middle
dots
data_quality:
score: 18
score: 19
max: 20
items:
- id: DQ-01
name: Feature Coverage
score: 7
max: 8
passed: true
comment: Shows trend, cyclical pattern, and volume well; could show more variation
in amplitude
comment: Shows upward trend, weekly cyclical pattern, increasing variance,
clear peaks/troughs — comprehensive but could show wider range
- id: DQ-02
name: Realistic Context
score: 7
max: 7
passed: true
comment: Website traffic is a perfect real-world scenario with believable
patterns
comment: Daily website visitors over a month is a real, neutral business scenario
matching the spec example
- id: DQ-03
name: Appropriate Scale
score: 4
score: 5
max: 5
passed: true
comment: Values 4000-8000 daily visitors are realistic; starting Y at 0 is
good but creates some empty space
comment: 3,500–8,200 daily visitors is realistic for a mid-sized website
code_quality:
score: 10
max: 10
Expand All @@ -164,40 +181,42 @@ review:
score: 3
max: 3
passed: true
comment: Simple imports → data → plot → save structure, no functions/classes
comment: 'Clean linear flow: imports → data generation → plot → save, 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 before all random operations
- id: CQ-03
name: Clean Imports
score: 2
max: 2
passed: true
comment: All imports are used
comment: All imports used (geom_smooth for LOWESS, annotate for Peak label,
etc.)
- id: CQ-04
name: No Deprecated API
score: 1
max: 1
passed: true
comment: Uses current plotnine API
comment: All API calls are current
- id: CQ-05
name: Output Correct
score: 1
max: 1
passed: true
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 ggplot grammar correctly but doesn't leverage plotnine-specific
features like faceting or stat transformations
passed: true
comment: 'Effective grammar of graphics: layer composition (geom_area + geom_line
+ geom_smooth), geom_smooth(method=lowess), scale_x_datetime, scale_y_continuous
with custom lambda labels, annotate for text'
verdict: APPROVED