Skip to content

Commit 986dc64

Browse files
feat(matplotlib): implement lollipop-basic (#5441)
## Implementation: `lollipop-basic` - python/matplotlib Implements the **python/matplotlib** version of `lollipop-basic`. **File:** `plots/lollipop-basic/implementations/python/matplotlib.py` **Parent Issue:** #934 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/24956604377)* --------- 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 674ec2b commit 986dc64

2 files changed

Lines changed: 199 additions & 134 deletions

File tree

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
lollipop-basic: Basic Lollipop Chart
3-
Library: matplotlib 3.10.8 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-23
3+
Library: matplotlib 3.10.9 | Python 3.14.4
4+
Quality: 88/100 | Updated: 2026-04-26
55
"""
66

7+
import os
8+
79
import matplotlib.pyplot as plt
810
import numpy as np
911

1012

11-
# Data: Product sales by category, sorted by value
13+
THEME = os.getenv("ANYPLOT_THEME", "light")
14+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
15+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
16+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
17+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
18+
19+
BRAND_GREEN = "#009E73"
20+
21+
# Data: Product sales by category
1222
categories = [
1323
"Electronics",
1424
"Clothing",
@@ -23,30 +33,35 @@
2333
]
2434
values = [87, 72, 65, 58, 52, 45, 41, 38, 32, 25]
2535

26-
# Sort by value descending for better readability
36+
# Sort by value descending for clear ranking
2737
sorted_indices = np.argsort(values)[::-1]
2838
categories = [categories[i] for i in sorted_indices]
2939
values = [values[i] for i in sorted_indices]
3040

31-
# Create plot (4800x2700 px)
32-
fig, ax = plt.subplots(figsize=(16, 9))
41+
fig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)
42+
ax.set_facecolor(PAGE_BG)
3343

34-
# Plot lollipop chart: stems + markers
3544
x_positions = np.arange(len(categories))
36-
ax.vlines(x_positions, ymin=0, ymax=values, color="#306998", linewidth=2.5)
37-
ax.scatter(x_positions, values, color="#FFD43B", s=300, zorder=3, edgecolors="#306998", linewidths=2)
45+
ax.vlines(x_positions, ymin=0, ymax=values, color=BRAND_GREEN, linewidth=2.5)
46+
ax.scatter(x_positions, values, color=BRAND_GREEN, s=300, zorder=3, edgecolors=PAGE_BG, linewidths=1.5)
3847

39-
# Labels and styling (scaled for 4800x2700)
40-
ax.set_xlabel("Product Category", fontsize=20)
41-
ax.set_ylabel("Sales (thousands)", fontsize=20)
42-
ax.set_title("lollipop-basic · matplotlib · pyplots.ai", fontsize=24)
48+
ax.set_xlabel("Product Category", fontsize=20, color=INK)
49+
ax.set_ylabel("Sales (thousands)", fontsize=20, color=INK)
50+
ax.set_title("lollipop-basic · matplotlib · anyplot.ai", fontsize=24, fontweight="medium", color=INK)
4351

4452
ax.set_xticks(x_positions)
4553
ax.set_xticklabels(categories, rotation=45, ha="right", fontsize=16)
46-
ax.tick_params(axis="y", labelsize=16)
54+
ax.tick_params(axis="both", labelsize=16, colors=INK_SOFT, labelcolor=INK_SOFT)
4755

4856
ax.set_ylim(0, max(values) * 1.1)
49-
ax.grid(True, alpha=0.3, linestyle="--", axis="y")
57+
58+
ax.spines["top"].set_visible(False)
59+
ax.spines["right"].set_visible(False)
60+
for s in ("left", "bottom"):
61+
ax.spines[s].set_color(INK_SOFT)
62+
63+
ax.yaxis.grid(True, alpha=0.15, color=INK, linewidth=0.8)
64+
ax.set_axisbelow(True)
5065

5166
plt.tight_layout()
52-
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
67+
plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG)

0 commit comments

Comments
 (0)