Skip to content

Commit 0c6ecb8

Browse files
feat(matplotlib): implement errorbar-basic (#5382)
## Implementation: `errorbar-basic` - python/matplotlib Implements the **python/matplotlib** version of `errorbar-basic`. **File:** `plots/errorbar-basic/implementations/python/matplotlib.py` **Parent Issue:** #973 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/24926861415)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent b4191bd commit 0c6ecb8

2 files changed

Lines changed: 206 additions & 135 deletions

File tree

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,66 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
errorbar-basic: Basic Error Bar Plot
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: 86/100 | Updated: 2026-04-25
55
"""
66

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

1012

13+
# Theme tokens
14+
THEME = os.getenv("ANYPLOT_THEME", "light")
15+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
16+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
17+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
18+
BRAND = "#009E73" # Okabe-Ito position 1
19+
1120
# Data - experimental measurements with associated uncertainties
1221
np.random.seed(42)
1322
categories = ["Control", "Treatment A", "Treatment B", "Treatment C", "Treatment D", "Treatment E"]
1423
x = np.arange(len(categories))
15-
y = np.array([25.3, 38.7, 42.1, 35.8, 48.2, 31.5]) # Mean values
24+
y = np.array([25.3, 38.7, 42.1, 35.8, 48.2, 31.5])
1625

1726
# Asymmetric errors: Treatment C and D have notably different lower/upper bounds
1827
asymmetric_lower = np.array([2.1, 3.5, 2.8, 6.5, 4.8, 2.5])
1928
asymmetric_upper = np.array([2.1, 3.5, 2.8, 2.8, 2.2, 2.5])
2029

2130
# Plot
22-
fig, ax = plt.subplots(figsize=(16, 9))
31+
fig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)
32+
ax.set_facecolor(PAGE_BG)
2333

24-
# Error bars with caps
2534
ax.errorbar(
2635
x,
2736
y,
2837
yerr=[asymmetric_lower, asymmetric_upper],
2938
fmt="o",
3039
markersize=15,
31-
color="#306998",
32-
ecolor="#306998",
40+
color=BRAND,
41+
ecolor=BRAND,
3342
elinewidth=3,
3443
capsize=10,
3544
capthick=3,
36-
alpha=0.9,
45+
markeredgecolor=PAGE_BG,
46+
markeredgewidth=1.2,
47+
alpha=0.95,
3748
)
3849

39-
# Styling
40-
ax.set_xlabel("Experimental Group", fontsize=20)
41-
ax.set_ylabel("Response Value (units)", fontsize=20)
42-
ax.set_title("errorbar-basic · matplotlib · pyplots.ai", fontsize=24)
50+
# Style
51+
ax.set_xlabel("Experimental Group", fontsize=20, color=INK)
52+
ax.set_ylabel("Response Value (units)", fontsize=20, color=INK)
53+
ax.set_title("errorbar-basic · matplotlib · anyplot.ai", fontsize=24, fontweight="medium", color=INK)
4354
ax.set_xticks(x)
44-
ax.set_xticklabels(categories, fontsize=16)
45-
ax.tick_params(axis="y", labelsize=16)
46-
ax.grid(True, alpha=0.3, linestyle="--", axis="y")
47-
48-
# Add some vertical padding
55+
ax.set_xticklabels(categories)
56+
ax.tick_params(axis="both", labelsize=16, colors=INK_SOFT)
57+
ax.spines["top"].set_visible(False)
58+
ax.spines["right"].set_visible(False)
59+
for s in ("left", "bottom"):
60+
ax.spines[s].set_color(INK_SOFT)
61+
ax.yaxis.grid(True, alpha=0.10, linewidth=0.8, color=INK)
62+
ax.set_axisbelow(True)
4963
ax.set_ylim(0, max(y + asymmetric_upper) * 1.15)
5064

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

0 commit comments

Comments
 (0)