Skip to content

Commit 042343f

Browse files
update(area-basic): altair — comprehensive quality review
Added traffic spike, interactive tooltips, cleaner axis config
1 parent ed0fb1b commit 042343f

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

plots/area-basic/implementations/altair.py

Lines changed: 13 additions & 12 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
3-
Library: altair 6.0.0 | Python 3.13.11
4-
Quality: 91/100 | Created: 2025-12-23
3+
Library: altair 6.0.0 | Python 3.14.2
4+
Quality: /100 | Updated: 2026-02-11
55
"""
66

77
import altair as alt
@@ -18,6 +18,8 @@
1818
weekly_pattern = np.array([1.2, 1.1, 1.0, 1.05, 1.15, 0.8, 0.7] * 5)[:30]
1919
noise = np.random.randn(30) * 300
2020
visitors = (base + trend) * weekly_pattern + noise
21+
# Add a traffic spike mid-month (e.g., marketing campaign on Jan 15)
22+
visitors[14] *= 1.4
2123
visitors = np.maximum(visitors, 1000).astype(int)
2224

2325
df = pd.DataFrame({"date": dates, "visitors": visitors})
@@ -27,20 +29,19 @@
2729
alt.Chart(df)
2830
.mark_area(opacity=0.4, color="#306998", line={"color": "#306998", "strokeWidth": 3})
2931
.encode(
30-
x=alt.X("date:T", title="Date", axis=alt.Axis(labelFontSize=18, titleFontSize=22)),
31-
y=alt.Y(
32-
"visitors:Q",
33-
title="Daily Visitors",
34-
scale=alt.Scale(domain=[0, df["visitors"].max() * 1.1]),
35-
axis=alt.Axis(labelFontSize=18, titleFontSize=22),
36-
),
32+
x=alt.X("date:T", title="Date"),
33+
y=alt.Y("visitors:Q", title="Daily Visitors (count)", scale=alt.Scale(domain=[0, df["visitors"].max() * 1.1])),
34+
tooltip=[
35+
alt.Tooltip("date:T", title="Date", format="%b %d, %Y"),
36+
alt.Tooltip("visitors:Q", title="Visitors", format=","),
37+
],
3738
)
3839
.properties(width=1600, height=900, title=alt.Title("area-basic · altair · pyplots.ai", fontSize=28))
39-
.configure_axis(grid=True, gridOpacity=0.3, gridDash=[4, 4])
40+
.configure_axis(grid=True, gridOpacity=0.3, gridDash=[4, 4], labelFontSize=18, titleFontSize=22)
4041
.configure_view(strokeWidth=0)
4142
)
4243

43-
# Save as PNG (1600 × 900 × 3 = 4800 × 2700 px)
44+
# Save as PNG (1600 × 900 at scale_factor=3 → 4800 × 2700 px)
4445
chart.save("plot.png", scale_factor=3.0)
4546

4647
# Save interactive HTML version

plots/area-basic/metadata/altair.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: altair
22
specification_id: area-basic
33
created: '2025-12-23T00:47:41Z'
4-
updated: '2025-12-23T01:21:39Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-11T22:20:05+00:00'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20447969752
77
issue: 0
8-
python_version: 3.13.11
8+
python_version: 3.14.2
99
library_version: 6.0.0
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-basic/altair/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-basic/altair/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/area-basic/altair/plot.html
13-
quality_score: 91
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques: []

0 commit comments

Comments
 (0)