Skip to content

Commit 4122f65

Browse files
feat(seaborn): implement line-timeseries (#6116)
## Implementation: `line-timeseries` - python/seaborn Implements the **python/seaborn** version of `line-timeseries`. **File:** `plots/line-timeseries/implementations/python/seaborn.py` **Parent Issue:** #2006 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/25590252408)* --------- 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 0012070 commit 4122f65

2 files changed

Lines changed: 204 additions & 127 deletions

File tree

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,82 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
line-timeseries: Time Series Line Plot
3-
Library: seaborn 0.13.2 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-26
3+
Library: seaborn 0.13.2 | Python 3.13.13
4+
Quality: 88/100 | Updated: 2026-05-09
55
"""
66

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

1315

16+
# Theme tokens
17+
THEME = os.getenv("ANYPLOT_THEME", "light")
18+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
19+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
20+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
21+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
22+
BRAND = "#009E73" # Okabe-Ito position 1
23+
24+
# Theme-adaptive seaborn configuration
25+
sns.set_theme(
26+
style="ticks",
27+
rc={
28+
"figure.facecolor": PAGE_BG,
29+
"axes.facecolor": PAGE_BG,
30+
"axes.edgecolor": INK_SOFT,
31+
"axes.labelcolor": INK,
32+
"text.color": INK,
33+
"xtick.color": INK_SOFT,
34+
"ytick.color": INK_SOFT,
35+
"grid.color": INK,
36+
"grid.alpha": 0.15,
37+
"legend.facecolor": ELEVATED_BG,
38+
"legend.edgecolor": INK_SOFT,
39+
},
40+
)
41+
1442
# Data: Daily temperature readings over 3 months
1543
np.random.seed(42)
1644
dates = pd.date_range(start="2024-01-01", periods=90, freq="D")
1745

18-
# Create realistic temperature pattern with seasonal variation and noise
1946
day_of_year = np.arange(90)
20-
base_temp = 5 + 10 * np.sin(2 * np.pi * (day_of_year + 10) / 365) # Seasonal trend
47+
base_temp = 5 + 10 * np.sin(2 * np.pi * (day_of_year + 10) / 365)
2148
noise = np.random.randn(90) * 3
2249
temperature = base_temp + noise
2350

2451
df = pd.DataFrame({"Date": dates, "Temperature (°C)": temperature})
2552

26-
# Create plot
27-
fig, ax = plt.subplots(figsize=(16, 9))
53+
# Plot
54+
fig, ax = plt.subplots(figsize=(16, 9), facecolor=PAGE_BG)
2855

29-
sns.lineplot(data=df, x="Date", y="Temperature (°C)", color="#306998", linewidth=3, ax=ax)
56+
sns.lineplot(data=df, x="Date", y="Temperature (°C)", color=BRAND, linewidth=3, ax=ax, errorbar=("ci", 95))
3057

31-
# Style adjustments for large canvas
32-
ax.set_xlabel("Date", fontsize=20)
33-
ax.set_ylabel("Temperature (°C)", fontsize=20)
34-
ax.set_title("line-timeseries · seaborn · pyplots.ai", fontsize=24)
35-
ax.tick_params(axis="both", labelsize=16)
58+
# Style
59+
ax.set_xlabel("Date", fontsize=20, color=INK)
60+
ax.set_ylabel("Temperature (°C)", fontsize=20, color=INK)
61+
ax.set_title("line-timeseries · seaborn · anyplot.ai", fontsize=24, fontweight="medium", color=INK)
62+
ax.tick_params(axis="both", labelsize=16, colors=INK_SOFT)
3663

37-
# Smart date formatting for months
64+
# Smart date formatting
3865
ax.xaxis.set_major_locator(mdates.MonthLocator())
3966
ax.xaxis.set_major_formatter(mdates.DateFormatter("%b %Y"))
4067
ax.xaxis.set_minor_locator(mdates.WeekdayLocator(byweekday=mdates.MO))
4168

4269
# Rotate labels to prevent overlap
4370
plt.setp(ax.get_xticklabels(), rotation=45, ha="right")
4471

45-
# Grid for readability
46-
ax.grid(True, alpha=0.3, linestyle="--")
72+
# Grid on both axes for readability
73+
ax.grid(True, alpha=0.15, linewidth=0.8, color=INK)
74+
75+
# Remove top and right spines
76+
ax.spines["top"].set_visible(False)
77+
ax.spines["right"].set_visible(False)
78+
for spine in ["left", "bottom"]:
79+
ax.spines[spine].set_color(INK_SOFT)
4780

4881
plt.tight_layout()
49-
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
82+
plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG)

0 commit comments

Comments
 (0)