From 440f3543d6ec6309f3f45c2ea32d16e4e7fa4b57 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 30 Dec 2025 11:29:50 +0000 Subject: [PATCH 1/3] feat(letsplot): implement area-stacked-percent --- .../implementations/letsplot.py | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 plots/area-stacked-percent/implementations/letsplot.py diff --git a/plots/area-stacked-percent/implementations/letsplot.py b/plots/area-stacked-percent/implementations/letsplot.py new file mode 100644 index 0000000000..1316b25dcb --- /dev/null +++ b/plots/area-stacked-percent/implementations/letsplot.py @@ -0,0 +1,89 @@ +"""pyplots.ai +area-stacked-percent: 100% Stacked Area Chart +Library: lets-plot | Python 3.13 +Quality: pending | Created: 2025-12-30 +""" + +import numpy as np +import pandas as pd +from lets_plot import ( + LetsPlot, + aes, + element_blank, + element_line, + element_rect, + element_text, + geom_area, + ggplot, + ggsize, + labs, + scale_fill_manual, + scale_x_continuous, + scale_y_continuous, + theme, + theme_minimal, +) +from lets_plot.export import ggsave + + +LetsPlot.setup_html() + +# Data - Market share evolution over 8 years +np.random.seed(42) + +years = list(range(2016, 2024)) + +# Simulate market share trends (values will be normalized to 100%) +company_a = [40, 38, 42, 45, 48, 52, 55, 58] # Growing leader +company_b = [35, 36, 33, 30, 28, 25, 23, 22] # Declining +company_c = [15, 16, 15, 16, 15, 14, 13, 12] # Stable small player +company_d = [10, 10, 10, 9, 9, 9, 9, 8] # Smallest, slight decline + +# Normalize to 100% +totals = [a + b + c + d for a, b, c, d in zip(company_a, company_b, company_c, company_d)] +company_a_pct = [a / t * 100 for a, t in zip(company_a, totals)] +company_b_pct = [b / t * 100 for b, t in zip(company_b, totals)] +company_c_pct = [c / t * 100 for c, t in zip(company_c, totals)] +company_d_pct = [d / t * 100 for d, t in zip(company_d, totals)] + +# Create long-format dataframe for lets-plot +df = pd.DataFrame( + { + "Year": years * 4, + "Share": company_a_pct + company_b_pct + company_c_pct + company_d_pct, + "Company": ["Company A"] * 8 + ["Company B"] * 8 + ["Company C"] * 8 + ["Company D"] * 8, + } +) + +# Set category order for proper stacking +df["Company"] = pd.Categorical( + df["Company"], categories=["Company D", "Company C", "Company B", "Company A"], ordered=True +) + +# Plot +plot = ( + ggplot(df, aes(x="Year", y="Share", fill="Company")) + + geom_area(position="fill", alpha=0.85) + + scale_fill_manual(values=["#9B59B6", "#2ECC71", "#FFD43B", "#306998"]) + + scale_x_continuous(breaks=list(range(2016, 2024))) + + scale_y_continuous(format=".0%") + + labs(x="Year", y="Market Share (%)", title="area-stacked-percent · letsplot · pyplots.ai") + + theme_minimal() + + theme( + plot_title=element_text(size=26), + axis_title=element_text(size=22), + axis_text=element_text(size=18), + legend_title=element_text(size=18), + legend_text=element_text(size=16), + panel_grid_major=element_line(color="#DDDDDD", size=0.3), + panel_grid_minor=element_blank(), + panel_background=element_rect(fill="#FAFAFA"), + ) + + ggsize(1600, 900) +) + +# Save PNG (scale=3 gives 4800x2700) +ggsave(plot, "plot.png", path=".", scale=3) + +# Save HTML for interactivity +ggsave(plot, "plot.html", path=".") From 09859704c5266243db736150185697afb9102765 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 30 Dec 2025 11:30:04 +0000 Subject: [PATCH 2/3] chore(letsplot): add metadata for area-stacked-percent --- .../metadata/letsplot.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 plots/area-stacked-percent/metadata/letsplot.yaml diff --git a/plots/area-stacked-percent/metadata/letsplot.yaml b/plots/area-stacked-percent/metadata/letsplot.yaml new file mode 100644 index 0000000000..78cbf0fbaf --- /dev/null +++ b/plots/area-stacked-percent/metadata/letsplot.yaml @@ -0,0 +1,19 @@ +# Per-library metadata for letsplot implementation of area-stacked-percent +# Auto-generated by impl-generate.yml + +library: letsplot +specification_id: area-stacked-percent +created: '2025-12-30T11:30:04Z' +updated: '2025-12-30T11:30:04Z' +generated_by: claude-opus-4-5-20251101 +workflow_run: 20595341903 +issue: 0 +python_version: 3.13.11 +library_version: 4.8.2 +preview_url: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot.png +preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot_thumb.png +preview_html: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot.html +quality_score: null +review: + strengths: [] + weaknesses: [] From f59572a2d1ed65f2f9dfa3eb5dfe34dac57715d5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 30 Dec 2025 11:36:57 +0000 Subject: [PATCH 3/3] chore(letsplot): update quality score 91 and review feedback for area-stacked-percent --- .../implementations/letsplot.py | 6 +++--- .../metadata/letsplot.yaml | 19 ++++++++++++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/plots/area-stacked-percent/implementations/letsplot.py b/plots/area-stacked-percent/implementations/letsplot.py index 1316b25dcb..d5949a54fe 100644 --- a/plots/area-stacked-percent/implementations/letsplot.py +++ b/plots/area-stacked-percent/implementations/letsplot.py @@ -1,7 +1,7 @@ -"""pyplots.ai +""" pyplots.ai area-stacked-percent: 100% Stacked Area Chart -Library: lets-plot | Python 3.13 -Quality: pending | Created: 2025-12-30 +Library: letsplot 4.8.2 | Python 3.13.11 +Quality: 91/100 | Created: 2025-12-30 """ import numpy as np diff --git a/plots/area-stacked-percent/metadata/letsplot.yaml b/plots/area-stacked-percent/metadata/letsplot.yaml index 78cbf0fbaf..0460ae2fce 100644 --- a/plots/area-stacked-percent/metadata/letsplot.yaml +++ b/plots/area-stacked-percent/metadata/letsplot.yaml @@ -1,10 +1,7 @@ -# Per-library metadata for letsplot implementation of area-stacked-percent -# Auto-generated by impl-generate.yml - library: letsplot specification_id: area-stacked-percent created: '2025-12-30T11:30:04Z' -updated: '2025-12-30T11:30:04Z' +updated: '2025-12-30T11:36:56Z' generated_by: claude-opus-4-5-20251101 workflow_run: 20595341903 issue: 0 @@ -13,7 +10,15 @@ library_version: 4.8.2 preview_url: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot.png preview_thumb: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot_thumb.png preview_html: https://storage.googleapis.com/pyplots-images/plots/area-stacked-percent/letsplot/plot.html -quality_score: null +quality_score: 91 review: - strengths: [] - weaknesses: [] + strengths: + - Excellent visual clarity with well-chosen colors that are colorblind-friendly + - Perfect 100% stacked area representation matching the spec exactly + - Realistic and informative market share scenario that clearly shows composition + changes over time + - Clean ggplot2-style code structure using lets-plot grammar of graphics + weaknesses: + - Year labels display with comma separators (2,016 instead of 2016) which looks + unnatural for year values + - The HTML export setup_html() call is unnecessary overhead for PNG-only output