Skip to content

Commit 44a1857

Browse files
feat(seaborn): implement stem-basic (#5629)
## Implementation: `stem-basic` - python/seaborn Implements the **python/seaborn** version of `stem-basic`. **File:** `plots/stem-basic/implementations/python/seaborn.py` **Parent Issue:** #972 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/25171839176)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
1 parent c766545 commit 44a1857

2 files changed

Lines changed: 192 additions & 134 deletions

File tree

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,73 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
stem-basic: Basic Stem Plot
3-
Library: seaborn 0.13.2 | Python 3.13.11
4-
Quality: 91/100 | Created: 2025-12-23
3+
Library: seaborn 0.13.2 | Python 3.13.13
4+
Quality: 88/100 | Updated: 2026-04-30
55
"""
66

7+
import os
8+
79
import matplotlib.pyplot as plt
810
import numpy as np
911
import pandas as pd
1012
import seaborn as sns
1113

1214

15+
THEME = os.getenv("ANYPLOT_THEME", "light")
16+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
17+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
18+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
19+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
20+
21+
BRAND = "#009E73"
22+
23+
sns.set_theme(
24+
style="ticks",
25+
rc={
26+
"figure.facecolor": PAGE_BG,
27+
"axes.facecolor": PAGE_BG,
28+
"axes.edgecolor": INK_SOFT,
29+
"axes.labelcolor": INK,
30+
"text.color": INK,
31+
"xtick.color": INK_SOFT,
32+
"ytick.color": INK_SOFT,
33+
"grid.color": INK,
34+
"grid.alpha": 0.10,
35+
"legend.facecolor": ELEVATED_BG,
36+
"legend.edgecolor": INK_SOFT,
37+
},
38+
)
39+
1340
# Data - Discrete signal samples (damped sinusoidal impulse response)
1441
np.random.seed(42)
1542
n_samples = 30
1643
x = np.arange(n_samples)
1744
y = np.exp(-0.1 * x) * np.sin(0.5 * x) * 2.5
1845

19-
# Create DataFrame for seaborn
2046
df = pd.DataFrame({"Sample Index": x, "Amplitude": y})
2147

22-
# Plot
2348
fig, ax = plt.subplots(figsize=(16, 9))
2449

2550
# Draw stems (thin vertical lines from baseline y=0 to data values)
26-
ax.vlines(x=df["Sample Index"], ymin=0, ymax=df["Amplitude"], color="#306998", linewidth=2.5, alpha=0.8)
51+
ax.vlines(x=df["Sample Index"], ymin=0, ymax=df["Amplitude"], color=BRAND, linewidth=2.5, alpha=0.8)
2752

2853
# Draw markers at top of stems using seaborn
2954
sns.scatterplot(
30-
data=df, x="Sample Index", y="Amplitude", s=300, color="#FFD43B", edgecolor="#306998", linewidth=2, ax=ax, zorder=3
55+
data=df, x="Sample Index", y="Amplitude", s=300, color=BRAND, edgecolor=PAGE_BG, linewidth=2, ax=ax, zorder=3
3156
)
3257

3358
# Draw baseline at y=0
34-
ax.axhline(y=0, color="#306998", linewidth=1.5, alpha=0.5)
59+
ax.axhline(y=0, color=INK_SOFT, linewidth=1.5, alpha=0.5)
3560

36-
# Styling
3761
ax.set_xlabel("Sample Index (n)", fontsize=20)
3862
ax.set_ylabel("Amplitude", fontsize=20)
39-
ax.set_title("stem-basic · seaborn · pyplots.ai", fontsize=24)
63+
ax.set_title("stem-basic · seaborn · anyplot.ai", fontsize=24)
4064
ax.tick_params(axis="both", labelsize=16)
41-
ax.grid(True, alpha=0.3, linestyle="--")
4265

43-
# Remove top and right spines for cleaner look
66+
ax.yaxis.grid(True, linestyle="-", linewidth=0.8, alpha=0.15)
67+
ax.set_axisbelow(True)
68+
4469
ax.spines["top"].set_visible(False)
4570
ax.spines["right"].set_visible(False)
4671

4772
plt.tight_layout()
48-
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
73+
plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG)

0 commit comments

Comments
 (0)