Skip to content

Commit 690b390

Browse files
feat(pygal): implement area-stacked-percent (#2682)
## Implementation: `area-stacked-percent` - pygal Implements the **pygal** version of `area-stacked-percent`. **File:** `plots/area-stacked-percent/implementations/pygal.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20595341160)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 2f7efd1 commit 690b390

2 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
""" pyplots.ai
2+
area-stacked-percent: 100% Stacked Area Chart
3+
Library: pygal 3.1.0 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import pygal
8+
from pygal.style import Style
9+
10+
11+
# Data - Market share evolution for tech product categories
12+
years = ["2018", "2019", "2020", "2021", "2022", "2023", "2024"]
13+
smartphones = [42, 40, 38, 36, 35, 33, 32]
14+
laptops = [28, 27, 26, 25, 24, 23, 22]
15+
tablets = [18, 19, 20, 21, 21, 22, 22]
16+
wearables = [8, 10, 12, 14, 16, 18, 20]
17+
accessories = [4, 4, 4, 4, 4, 4, 4]
18+
19+
# Custom style for large canvas
20+
custom_style = Style(
21+
background="white",
22+
plot_background="white",
23+
foreground="#333333",
24+
foreground_strong="#333333",
25+
foreground_subtle="#666666",
26+
colors=("#306998", "#FFD43B", "#3CB371", "#FF6B6B", "#9B59B6"),
27+
title_font_size=72,
28+
label_font_size=48,
29+
major_label_font_size=42,
30+
legend_font_size=42,
31+
value_font_size=36,
32+
opacity=0.85,
33+
opacity_hover=0.95,
34+
transition="250ms ease-in",
35+
)
36+
37+
# Create stacked area chart with percentage mode
38+
chart = pygal.StackedLine(
39+
width=4800,
40+
height=2700,
41+
style=custom_style,
42+
title="area-stacked-percent · pygal · pyplots.ai",
43+
x_title="Year",
44+
y_title="Market Share (%)",
45+
fill=True,
46+
stack_from_top=False,
47+
show_y_guides=True,
48+
show_x_guides=False,
49+
y_labels_major_every=2,
50+
truncate_legend=-1,
51+
legend_at_bottom=False,
52+
legend_box_size=30,
53+
margin=50,
54+
spacing=40,
55+
dots_size=8,
56+
stroke_style={"width": 3},
57+
)
58+
59+
# Set x-axis labels
60+
chart.x_labels = years
61+
62+
# Add data series (values already sum to 100% each year)
63+
chart.add("Smartphones", smartphones)
64+
chart.add("Laptops", laptops)
65+
chart.add("Tablets", tablets)
66+
chart.add("Wearables", wearables)
67+
chart.add("Accessories", accessories)
68+
69+
# Save as PNG and HTML
70+
chart.render_to_png("plot.png")
71+
chart.render_to_file("plot.html")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library: pygal
2+
specification_id: area-stacked-percent
3+
created: '2025-12-30T11:26:39Z'
4+
updated: '2025-12-30T11:36:32Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20595341160
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.1.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/pygal/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/pygal/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/pygal/plot.html
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Correct implementation of 100% stacked area using StackedLine with fill=True
17+
- Excellent title format following pyplots.ai convention
18+
- Well-chosen, realistic market share scenario with clear temporal trends
19+
- Good color palette with five distinguishable colors
20+
- Clean KISS code structure with no unnecessary complexity
21+
- Properly outputs both PNG and HTML formats
22+
- Custom style with appropriate font sizes for large canvas
23+
weaknesses:
24+
- Y-axis range starts at ~40 instead of 0, which can be misleading for percentage
25+
visualization where the full 0-100% context matters
26+
- Data is somewhat artificial with perfectly linear trends and static values (Accessories
27+
at exactly 4% for all years)

0 commit comments

Comments
 (0)