Skip to content

Commit 13438d2

Browse files
Merge branch 'main' into implementation/radar-basic/seaborn
2 parents 22e663b + 20beb7e commit 13438d2

2 files changed

Lines changed: 205 additions & 165 deletions

File tree

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,80 @@
1-
""" pyplots.ai
1+
""" anyplot.ai
22
radar-basic: Basic Radar Chart
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.13.13
4+
Quality: 87/100 | Updated: 2026-04-29
55
"""
66

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

1012

11-
# Data - Employee performance comparison across competencies (deterministic, no random)
13+
# Theme
14+
THEME = os.getenv("ANYPLOT_THEME", "light")
15+
PAGE_BG = "#FAF8F1" if THEME == "light" else "#1A1A17"
16+
ELEVATED_BG = "#FFFDF6" if THEME == "light" else "#242420"
17+
INK = "#1A1A17" if THEME == "light" else "#F0EFE8"
18+
INK_SOFT = "#4A4A44" if THEME == "light" else "#B8B7B0"
19+
INK_MUTED = "#6B6A63" if THEME == "light" else "#A8A79F"
20+
21+
SERIES_1 = "#009E73" # Okabe-Ito position 1
22+
SERIES_2 = "#D55E00" # Okabe-Ito position 2
23+
24+
# Data - Employee performance comparison across six competencies
1225
categories = ["Communication", "Technical Skills", "Teamwork", "Problem Solving", "Leadership", "Creativity"]
13-
employee_a = [85, 90, 78, 88, 72, 80] # Senior Developer
14-
employee_b = [75, 70, 92, 65, 85, 88] # Team Lead
26+
senior_dev = [82, 94, 75, 90, 48, 78] # Strong technical, weaker leadership
27+
team_lead = [88, 55, 96, 62, 91, 70] # Strong people skills, weaker technical
1528

16-
# Number of variables
1729
num_vars = len(categories)
18-
19-
# Compute angle for each axis
2030
angles = np.linspace(0, 2 * np.pi, num_vars, endpoint=False).tolist()
2131

22-
# Close the polygons by appending first value
23-
employee_a_closed = employee_a + [employee_a[0]]
24-
employee_b_closed = employee_b + [employee_b[0]]
32+
senior_dev_closed = senior_dev + [senior_dev[0]]
33+
team_lead_closed = team_lead + [team_lead[0]]
2534
angles_closed = angles + [angles[0]]
2635

27-
# Create square plot (better for radar charts)
28-
_, ax = plt.subplots(figsize=(12, 12), subplot_kw={"polar": True})
36+
# Plot
37+
fig, ax = plt.subplots(figsize=(12, 12), subplot_kw={"polar": True}, facecolor=PAGE_BG)
38+
ax.set_facecolor(PAGE_BG)
2939

30-
# Plot Employee A (Python Blue)
31-
ax.fill(angles_closed, employee_a_closed, color="#306998", alpha=0.25)
40+
# Start from top (12 o'clock), go clockwise
41+
ax.set_theta_offset(np.pi / 2)
42+
ax.set_theta_direction(-1)
43+
44+
# Senior Developer
45+
ax.fill(angles_closed, senior_dev_closed, color=SERIES_1, alpha=0.25)
3246
ax.plot(
33-
angles_closed, employee_a_closed, color="#306998", linewidth=3, marker="o", markersize=12, label="Senior Developer"
47+
angles_closed, senior_dev_closed, color=SERIES_1, linewidth=3, marker="o", markersize=10, label="Senior Developer"
3448
)
3549

36-
# Plot Employee B (Python Yellow)
37-
ax.fill(angles_closed, employee_b_closed, color="#FFD43B", alpha=0.25)
38-
ax.plot(angles_closed, employee_b_closed, color="#FFD43B", linewidth=3, marker="o", markersize=12, label="Team Lead")
50+
# Team Lead
51+
ax.fill(angles_closed, team_lead_closed, color=SERIES_2, alpha=0.25)
52+
ax.plot(angles_closed, team_lead_closed, color=SERIES_2, linewidth=3, marker="o", markersize=10, label="Team Lead")
3953

40-
# Set the angle for each axis label
54+
# Axis configuration
4155
ax.set_xticks(angles)
42-
ax.set_xticklabels(categories, fontsize=18)
56+
ax.set_xticklabels(categories, fontsize=18, color=INK)
4357

44-
# Set radial limits and gridlines
4558
ax.set_ylim(0, 100)
4659
ax.set_yticks([20, 40, 60, 80, 100])
60+
ax.set_rlabel_position(22.5)
61+
ax.set_yticklabels(["20", "40", "60", "80", "100"], fontsize=13, color=INK_MUTED)
4762

48-
# Position radial tick labels outside the chart for better clarity
49-
ax.set_rlabel_position(22.5) # Move labels to 22.5 degrees for better visibility
50-
ax.set_yticklabels(["20", "40", "60", "80", "100"], fontsize=14, color="#555555", fontweight="medium")
51-
52-
# Style grid
53-
ax.grid(True, alpha=0.4, linestyle="--", linewidth=1.5)
63+
# Grid and outer spine
64+
ax.grid(True, alpha=0.18, linewidth=1.0, color=INK)
65+
ax.spines["polar"].set_color(INK_SOFT)
66+
ax.spines["polar"].set_linewidth(0.8)
5467

5568
# Title
56-
ax.set_title("Employee Performance · radar-basic · matplotlib · pyplots.ai", fontsize=24, pad=40)
69+
ax.set_title(
70+
"Employee Performance · radar-basic · matplotlib · anyplot.ai", fontsize=24, fontweight="medium", pad=40, color=INK
71+
)
5772

58-
# Legend (positioned to not cover data)
59-
ax.legend(loc="upper right", bbox_to_anchor=(1.3, 1.05), fontsize=16)
73+
# Legend
74+
leg = ax.legend(loc="upper right", bbox_to_anchor=(1.35, 1.1), fontsize=16)
75+
leg.get_frame().set_facecolor(ELEVATED_BG)
76+
leg.get_frame().set_edgecolor(INK_SOFT)
77+
plt.setp(leg.get_texts(), color=INK_SOFT)
6078

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

0 commit comments

Comments
 (0)