|
1 | | -""" pyplots.ai |
| 1 | +""" anyplot.ai |
2 | 2 | stem-basic: Basic Stem Plot |
3 | | -Library: matplotlib 3.10.8 | Python 3.13.11 |
4 | | -Quality: 94/100 | Created: 2025-12-23 |
| 3 | +Library: matplotlib 3.10.9 | Python 3.13.13 |
| 4 | +Quality: 91/100 | Updated: 2026-04-30 |
5 | 5 | """ |
6 | 6 |
|
| 7 | +import os |
| 8 | + |
7 | 9 | import matplotlib.pyplot as plt |
8 | 10 | import numpy as np |
9 | 11 |
|
10 | 12 |
|
11 | | -# Data - Discrete signal samples (simulating a damped oscillation) |
| 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" |
| 19 | + |
| 20 | +# Data - discrete damped oscillation signal |
12 | 21 | np.random.seed(42) |
13 | 22 | x = np.arange(0, 30) |
14 | 23 | y = np.exp(-x / 10) * np.cos(x * 0.8) + np.random.randn(30) * 0.05 |
15 | 24 |
|
16 | | -# Create plot (4800x2700 px) |
17 | | -fig, ax = plt.subplots(figsize=(16, 9)) |
| 25 | +# Plot |
| 26 | +fig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG) |
| 27 | +ax.set_facecolor(PAGE_BG) |
18 | 28 |
|
19 | | -# Stem plot with custom styling |
20 | | -markerline, stemlines, baseline = ax.stem(x, y, basefmt="k-") |
21 | | -plt.setp(stemlines, linewidth=2, color="#306998", alpha=0.8) |
22 | | -plt.setp(markerline, markersize=12, color="#306998", markeredgecolor="white", markeredgewidth=2) |
23 | | -plt.setp(baseline, linewidth=2, color="#333333") |
| 29 | +markerline, stemlines, baseline = ax.stem(x, y, basefmt="-") |
| 30 | +plt.setp(stemlines, linewidth=2, color=BRAND, alpha=0.8) |
| 31 | +plt.setp(markerline, markersize=12, color=BRAND, markeredgecolor=PAGE_BG, markeredgewidth=2) |
| 32 | +plt.setp(baseline, linewidth=1.5, color=INK_SOFT) |
24 | 33 |
|
25 | | -# Labels and styling (scaled font sizes for 4800x2700) |
26 | | -ax.set_xlabel("Sample Index", fontsize=20) |
27 | | -ax.set_ylabel("Amplitude", fontsize=20) |
28 | | -ax.set_title("stem-basic · matplotlib · pyplots.ai", fontsize=24) |
29 | | -ax.tick_params(axis="both", labelsize=16) |
30 | | -ax.grid(True, alpha=0.3, linestyle="--") |
| 34 | +# Style |
| 35 | +ax.set_xlabel("Sample Index (n)", fontsize=20, color=INK) |
| 36 | +ax.set_ylabel("Amplitude (V)", fontsize=20, color=INK) |
| 37 | +ax.set_title("stem-basic · matplotlib · anyplot.ai", fontsize=24, fontweight="medium", color=INK) |
| 38 | +ax.tick_params(axis="both", labelsize=16, colors=INK_SOFT) |
| 39 | +ax.spines["top"].set_visible(False) |
| 40 | +ax.spines["right"].set_visible(False) |
| 41 | +for s in ("left", "bottom"): |
| 42 | + ax.spines[s].set_color(INK_SOFT) |
| 43 | +ax.yaxis.grid(True, alpha=0.12, linewidth=0.8, color=INK) |
31 | 44 |
|
| 45 | +# Save |
32 | 46 | plt.tight_layout() |
33 | | -plt.savefig("plot.png", dpi=300, bbox_inches="tight") |
| 47 | +plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG) |
0 commit comments