Skip to content

Commit 4dd1d0b

Browse files
feat(altair): implement area-basic (#432)
## Summary Implements `area-basic` for **altair** library. **Parent Issue:** #201 **Sub-Issue:** #395 **Base Branch:** `plot/area-basic` **Attempt:** 1/3 ## Implementation - `plots/altair/area/area-basic/default.py` ## Changes - Uses `mark_area()` with inline `line` parameter for cleaner code - Extended data from 6 to 12 months for richer visualization - Added `configure_view(strokeWidth=0)` to remove chart border - Configured proper font sizes for title, axis labels, and tick labels - Subtle grid with `gridOpacity=0.3` - Outputs 4800×2700px PNG (1600×900 × scale_factor=3.0) Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
1 parent c57acb0 commit 4dd1d0b

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

plots/altair/area/area-basic/default.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,25 @@
88

99

1010
# Data
11-
data = pd.DataFrame({"month": [1, 2, 3, 4, 5, 6], "sales": [100, 150, 130, 180, 200, 220]})
11+
data = pd.DataFrame(
12+
{
13+
"month": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
14+
"sales": [100, 150, 130, 180, 200, 220, 195, 240, 260, 230, 280, 310],
15+
}
16+
)
1217

1318
# Create chart with area and line
14-
area = (
19+
chart = (
1520
alt.Chart(data)
16-
.mark_area(opacity=0.5, color="#306998")
21+
.mark_area(opacity=0.5, color="#306998", line={"color": "#306998", "strokeWidth": 2})
1722
.encode(
1823
x=alt.X("month:Q", title="Month", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
1924
y=alt.Y("sales:Q", title="Sales", axis=alt.Axis(labelFontSize=16, titleFontSize=20)),
2025
)
21-
)
22-
23-
line = alt.Chart(data).mark_line(color="#306998", strokeWidth=2).encode(x="month:Q", y="sales:Q")
24-
25-
chart = (
26-
(area + line)
27-
.properties(width=1600, height=900, title=alt.Title("Basic Area Chart", fontSize=20))
26+
.properties(width=1600, height=900, title=alt.TitleParams(text="Basic Area Chart", fontSize=20))
27+
.configure_view(strokeWidth=0)
2828
.configure_axis(grid=True, gridOpacity=0.3)
2929
)
3030

31-
# Save
31+
# Save (1600 × 900 × 3 = 4800 × 2700)
3232
chart.save("plot.png", scale_factor=3.0)

0 commit comments

Comments
 (0)