Skip to content

Commit 3edcd9a

Browse files
feat(seaborn): implement polar-line (#2700)
## Implementation: `polar-line` - seaborn Implements the **seaborn** version of `polar-line`. **File:** `plots/polar-line/implementations/seaborn.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20596056971)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent f991938 commit 3edcd9a

2 files changed

Lines changed: 86 additions & 0 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
""" pyplots.ai
2+
polar-line: Polar Line Plot
3+
Library: seaborn 0.13.2 | Python 3.13.11
4+
Quality: 91/100 | Created: 2025-12-30
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
import seaborn as sns
10+
11+
12+
# Set seaborn style for consistent aesthetics
13+
sns.set_theme(style="whitegrid")
14+
15+
# Data: Monthly average temperatures for two cities (cyclical pattern)
16+
np.random.seed(42)
17+
months = np.linspace(0, 2 * np.pi, 13) # 12 months + closing point
18+
19+
# City A: Temperate climate with moderate seasonal variation
20+
city_a_temps = np.array([5, 7, 12, 16, 20, 24, 26, 25, 21, 15, 9, 5, 5])
21+
22+
# City B: More extreme seasonal variation
23+
city_b_temps = np.array([0, 2, 8, 14, 20, 26, 30, 29, 23, 14, 6, 1, 0])
24+
25+
# Create polar plot
26+
fig, ax = plt.subplots(figsize=(12, 12), subplot_kw={"projection": "polar"})
27+
28+
# Use seaborn color palette
29+
colors = sns.color_palette(["#306998", "#FFD43B"])
30+
31+
# Plot lines using seaborn-styled matplotlib
32+
ax.plot(months, city_a_temps, color=colors[0], linewidth=3.5, marker="o", markersize=12, label="Coastal City")
33+
ax.plot(months, city_b_temps, color=colors[1], linewidth=3.5, marker="s", markersize=12, label="Inland City")
34+
35+
# Fill area under curves with transparency
36+
ax.fill(months, city_a_temps, color=colors[0], alpha=0.15)
37+
ax.fill(months, city_b_temps, color=colors[1], alpha=0.15)
38+
39+
# Set month labels
40+
month_labels = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
41+
ax.set_xticks(np.linspace(0, 2 * np.pi, 12, endpoint=False))
42+
ax.set_xticklabels(month_labels, fontsize=18)
43+
44+
# Style radial axis
45+
ax.set_ylim(0, 35)
46+
ax.set_yticks([0, 10, 20, 30])
47+
ax.set_yticklabels(["0°C", "10°C", "20°C", "30°C"], fontsize=14)
48+
49+
# Title and legend
50+
ax.set_title("Monthly Temperature Patterns · polar-line · seaborn · pyplots.ai", fontsize=22, pad=30, fontweight="bold")
51+
ax.legend(loc="upper right", bbox_to_anchor=(1.15, 1.1), fontsize=16, frameon=True, fancybox=True)
52+
53+
# Customize grid
54+
ax.grid(True, alpha=0.3, linestyle="--")
55+
ax.set_theta_zero_location("N") # Start from top (January at 12 o'clock)
56+
ax.set_theta_direction(-1) # Clockwise direction
57+
58+
plt.tight_layout()
59+
plt.savefig("plot.png", dpi=300, bbox_inches="tight", facecolor="white")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
library: seaborn
2+
specification_id: polar-line
3+
created: '2025-12-30T12:05:11Z'
4+
updated: '2025-12-30T12:09:42Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20596056971
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 0.13.2
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/polar-line/seaborn/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/polar-line/seaborn/plot_thumb.png
12+
preview_html: null
13+
quality_score: 91
14+
review:
15+
strengths:
16+
- Excellent use of polar projection for cyclical monthly data
17+
- Clear visual distinction between two temperature series with contrasting colors
18+
and marker shapes
19+
- Good use of filled areas to enhance visual comparison
20+
- Proper clockwise month arrangement starting from January at top
21+
- Clean, readable code structure following KISS principles
22+
- Realistic and educational data scenario (coastal vs inland temperature patterns)
23+
- Appropriate radial axis labels with temperature units
24+
weaknesses:
25+
- Does not use seaborn plotting functions (only styling utilities); implementation
26+
relies entirely on matplotlib for actual plotting
27+
- Legend placement causes overlap with title area

0 commit comments

Comments
 (0)