Skip to content

Commit e8dff10

Browse files
feat(seaborn): implement rose-basic (#5592)
## Implementation: `rose-basic` - python/seaborn Implements the **python/seaborn** version of `rose-basic`. **File:** `plots/rose-basic/implementations/python/seaborn.py` **Parent Issue:** #1003 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/25151670488)* --------- 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 20e5f26 commit e8dff10

2 files changed

Lines changed: 209 additions & 159 deletions

File tree

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,87 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
rose-basic: Basic Rose Chart
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: 82/100 | Updated: 2026-04-30
55
"""
66

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

1113

14+
# Theme tokens
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+
# Apply seaborn theme with full adaptive chrome
22+
sns.set_theme(
23+
style="ticks",
24+
rc={
25+
"figure.facecolor": PAGE_BG,
26+
"axes.facecolor": PAGE_BG,
27+
"axes.edgecolor": INK_SOFT,
28+
"axes.labelcolor": INK,
29+
"text.color": INK,
30+
"xtick.color": INK_SOFT,
31+
"ytick.color": INK_SOFT,
32+
"grid.color": INK_SOFT,
33+
"grid.alpha": 0.12,
34+
"legend.facecolor": ELEVATED_BG,
35+
"legend.edgecolor": INK_SOFT,
36+
},
37+
)
38+
1239
# Data: Monthly rainfall (mm) showing seasonal patterns
1340
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1441
rainfall = [89, 72, 95, 112, 135, 168, 142, 125, 98, 76, 82, 91]
1542

1643
# Calculate angles - start at top (12 o'clock position)
1744
n_categories = len(months)
1845
angles = np.linspace(0, 2 * np.pi, n_categories, endpoint=False)
19-
20-
# Bar width (slightly less than full segment for gaps)
2146
width = 2 * np.pi / n_categories * 0.85
2247

2348
# Create figure with polar projection (square format for radial plot)
2449
fig, ax = plt.subplots(figsize=(12, 12), subplot_kw={"projection": "polar"})
50+
fig.patch.set_facecolor(PAGE_BG)
51+
ax.set_facecolor(PAGE_BG)
2552

26-
# Use seaborn color palette - Blues gradient for rainfall theme
27-
palette = sns.color_palette("Blues", n_colors=n_categories)
53+
# Use seaborn Blues palette for sequential rainfall depth; skip lightest shades
54+
palette = sns.color_palette("Blues", n_colors=n_categories + 3)[3:]
2855

2956
# Plot bars - radius proportional to value
30-
ax.bar(angles, rainfall, width=width, bottom=0, color=palette, edgecolor="white", linewidth=2, alpha=0.9)
57+
ax.bar(angles, rainfall, width=width, bottom=0, color=palette, edgecolor=PAGE_BG, linewidth=1.5, alpha=0.92)
3158

32-
# Configure polar axis - start at top, go clockwise
33-
ax.set_theta_offset(np.pi / 2) # Start at top (12 o'clock)
34-
ax.set_theta_direction(-1) # Clockwise direction
59+
# Configure polar axis - start at top (12 o'clock), clockwise
60+
ax.set_theta_offset(np.pi / 2)
61+
ax.set_theta_direction(-1)
3562

36-
# Set category labels at correct positions
63+
# Category labels
3764
ax.set_xticks(angles)
38-
ax.set_xticklabels(months, fontsize=20, fontweight="bold")
65+
ax.set_xticklabels(months, fontsize=20, fontweight="bold", color=INK)
3966

40-
# Configure radial gridlines and labels
67+
# Radial gridlines and labels
4168
max_val = max(rainfall)
4269
ax.set_ylim(0, max_val * 1.15)
4370
ax.set_yticks([50, 100, 150])
44-
ax.set_yticklabels(["50 mm", "100 mm", "150 mm"], fontsize=14, color="#555555")
71+
ax.set_yticklabels(["50 mm", "100 mm", "150 mm"], fontsize=14, color=INK_SOFT)
4572

46-
# Style the grid
47-
ax.grid(True, alpha=0.3, linestyle="--", linewidth=1.5, color="#888888")
73+
# Grid and spine styling
74+
ax.grid(True, alpha=0.18, linestyle="--", linewidth=1.2, color=INK_SOFT)
4875
ax.spines["polar"].set_visible(False)
4976

50-
# Add title with proper formatting
77+
# Title
5178
ax.set_title(
52-
"Monthly Rainfall (mm) · rose-basic · seaborn · pyplots.ai", fontsize=24, fontweight="bold", pad=35, color="#333333"
79+
"Monthly Rainfall (mm) · rose-basic · seaborn · anyplot.ai", fontsize=24, fontweight="bold", pad=35, color=INK
5380
)
5481

55-
# Add value labels on each bar
82+
# Value labels on each bar
5683
for angle, value in zip(angles, rainfall, strict=True):
57-
# Position label just outside the bar
58-
label_radius = value + 12
59-
ax.text(angle, label_radius, f"{value}", ha="center", va="center", fontsize=14, fontweight="bold", color="#306998")
84+
ax.text(angle, value + 12, f"{value}", ha="center", va="center", fontsize=14, fontweight="bold", color=INK_SOFT)
6085

6186
plt.tight_layout()
62-
plt.savefig("plot.png", dpi=300, bbox_inches="tight", facecolor="white")
87+
plt.savefig(f"plot-{THEME}.png", dpi=300, bbox_inches="tight", facecolor=PAGE_BG)

0 commit comments

Comments
 (0)