Skip to content

Commit 43e0314

Browse files
feat(plotnine): implement lollipop-basic (#5446)
## Implementation: `lollipop-basic` - python/plotnine Implements the **python/plotnine** version of `lollipop-basic`. **File:** `plots/lollipop-basic/implementations/python/plotnine.py` **Parent Issue:** #934 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/24957093138)* --------- 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 d029ad4 commit 43e0314

2 files changed

Lines changed: 180 additions & 136 deletions

File tree

plots/lollipop-basic/implementations/python/plotnine.py

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,32 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
lollipop-basic: Basic Lollipop Chart
3-
Library: plotnine 0.15.2 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-23
3+
Library: plotnine 0.15.3 | Python 3.14.4
4+
Quality: 85/100 | Updated: 2026-04-26
55
"""
66

7+
import os
8+
79
import pandas as pd
8-
from plotnine import aes, element_line, element_text, geom_point, geom_segment, ggplot, labs, theme, theme_minimal
10+
from plotnine import (
11+
aes,
12+
element_line,
13+
element_rect,
14+
element_text,
15+
geom_point,
16+
geom_segment,
17+
ggplot,
18+
ggsave,
19+
labs,
20+
theme,
21+
theme_minimal,
22+
)
23+
924

25+
THEME = os.getenv("ANYPLOT_THEME", "light")
26+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
27+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
28+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
29+
BRAND = "#009E73"
1030

1131
# Data - Product sales by category, sorted by value
1232
data = {
@@ -32,23 +52,24 @@
3252
# Plot
3353
plot = (
3454
ggplot(df, aes(x="category", y="value"))
35-
# Stems - thin lines from baseline to value
36-
+ geom_segment(aes(x="category", xend="category", y=0, yend="value"), color="#306998", size=1.5)
37-
# Circular markers at data values
38-
+ geom_point(color="#306998", size=6, fill="#306998")
39-
+ labs(x="Product Category", y="Sales (thousands $)", title="lollipop-basic · plotnine · pyplots.ai")
55+
+ geom_segment(aes(x="category", xend="category", y=0, yend="value"), color=BRAND, size=1.5)
56+
+ geom_point(color=BRAND, size=6, fill=BRAND)
57+
+ labs(x="Product Category", y="Sales (thousands $)", title="lollipop-basic · plotnine · anyplot.ai")
4058
+ theme_minimal()
4159
+ theme(
4260
figure_size=(16, 9),
43-
text=element_text(size=14),
44-
axis_title=element_text(size=20),
45-
axis_text=element_text(size=16),
46-
axis_text_x=element_text(angle=45, ha="right"),
47-
plot_title=element_text(size=24),
61+
plot_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
62+
panel_background=element_rect(fill=PAGE_BG, color=PAGE_BG),
63+
text=element_text(size=14, color=INK),
64+
axis_title=element_text(size=20, color=INK),
65+
axis_text=element_text(size=16, color=INK_SOFT),
66+
axis_text_x=element_text(angle=45, ha="right", color=INK_SOFT),
67+
axis_line=element_line(color=INK_SOFT),
68+
plot_title=element_text(size=24, color=INK),
4869
panel_grid_minor=element_line(alpha=0),
4970
panel_grid_major_x=element_line(alpha=0),
50-
panel_grid_major_y=element_line(alpha=0.3, linetype="dashed"),
71+
panel_grid_major_y=element_line(color=INK, alpha=0.15, size=0.3),
5172
)
5273
)
5374

54-
plot.save("plot.png", dpi=300)
75+
ggsave(plot, filename=f"plot-{THEME}.png", dpi=300, width=16, height=9)

0 commit comments

Comments
 (0)