Skip to content

Commit e1f46c2

Browse files
update(area-basic): matplotlib — comprehensive quality review
Added viral blog post spike with annotation, improved data range, enhanced title
1 parent ed0fb1b commit e1f46c2

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

plots/area-basic/implementations/matplotlib.py

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
area-basic: Basic Area Chart
33
Library: matplotlib 3.10.8 | Python 3.14.2
4-
Quality: 95/100 | Created: 2025-12-23
4+
Quality: /100 | Updated: 2026-02-11
55
"""
66

77
import matplotlib.colors as mcolors
@@ -11,26 +11,29 @@
1111
from matplotlib.path import Path
1212

1313

14-
# Data - daily website visitors over a month with weekend dips
14+
# Data - daily website visitors over a month with weekend dips and a viral spike
1515
np.random.seed(42)
1616
days = np.arange(1, 31)
17-
base_visitors = 5000 + np.linspace(0, 2500, 30) # Upward trend
17+
base_visitors = 3000 + np.linspace(0, 2000, 30) # Upward trend from 3k to 5k
1818
weekend_effect = np.array([-1200 if d % 7 in (0, 6) else 0 for d in days]) # Weekend dips
19-
noise = np.random.randn(30) * 400
19+
noise = np.random.randn(30) * 300
2020
visitors = base_visitors + weekend_effect + noise
21-
visitors = np.clip(visitors, 2000, 10000)
21+
# Viral blog post spike on day 18
22+
visitors[17] = 8200
23+
visitors[18] = 6800
24+
visitors = np.clip(visitors, 1000, 10000)
2225

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

26-
y_max = visitors.max() * 1.15
29+
y_max = visitors.max() * 1.12
2730

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

33-
# Build clip path manually from fill_between polygon
36+
# Build clip path from area polygon
3437
verts = [(days[0], 0)]
3538
for d, v in zip(days, visitors, strict=True):
3639
verts.append((d, v))
@@ -49,10 +52,22 @@
4952
# Solid line on top
5053
ax.plot(days, visitors, color="#306998", linewidth=3, zorder=3)
5154

55+
# Annotate the viral spike
56+
ax.annotate(
57+
"Viral post",
58+
xy=(18, visitors[17]),
59+
xytext=(22, visitors[17] + 400),
60+
fontsize=16,
61+
color="#306998",
62+
fontweight="bold",
63+
arrowprops={"arrowstyle": "->", "color": "#306998", "lw": 2},
64+
zorder=4,
65+
)
66+
5267
# Labels and styling
5368
ax.set_xlabel("Day of Month", fontsize=20)
5469
ax.set_ylabel("Daily Visitors (count)", fontsize=20)
55-
ax.set_title("area-basic · matplotlib · pyplots.ai", fontsize=24)
70+
ax.set_title("Website Traffic · area-basic · matplotlib · pyplots.ai", fontsize=24)
5671
ax.tick_params(axis="both", labelsize=16)
5772
ax.grid(True, alpha=0.3, linestyle="--")
5873

plots/area-basic/metadata/matplotlib.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library: matplotlib
22
specification_id: area-basic
33
created: '2025-12-23T00:46:12Z'
4-
updated: '2026-02-11T20:57:35Z'
4+
updated: '2026-02-11T22:20:05+00:00'
55
generated_by: claude-opus-4-6
66
workflow_run: 20447957143
77
issue: 0
@@ -10,7 +10,7 @@ library_version: 3.10.8
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/matplotlib/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/matplotlib/plot_thumb.png
1212
preview_html: null
13-
quality_score: 95
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques:

0 commit comments

Comments
 (0)