Skip to content

Commit 51ee5ca

Browse files
feat(seaborn): implement heatmap-basic (#1379)
## Implementation: `heatmap-basic` - seaborn Implements the **seaborn** version of `heatmap-basic`. **File:** `plots/heatmap-basic/implementations/seaborn.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20447949053)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 8d8bbcc commit 51ee5ca

2 files changed

Lines changed: 41 additions & 23 deletions

File tree

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" pyplots.ai
22
heatmap-basic: Basic Heatmap
33
Library: seaborn 0.13.2 | Python 3.13.11
4-
Quality: 94/100 | Created: 2025-12-14
4+
Quality: 93/100 | Created: 2025-12-23
55
"""
66

77
import matplotlib.pyplot as plt
@@ -14,15 +14,18 @@
1414
departments = ["Sales", "Marketing", "Engineering", "Support", "Finance", "HR", "Operations"]
1515
months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
1616

17-
# Generate performance data (values ranging from -50 to 100)
18-
data = np.random.randn(len(departments), len(months)) * 30 + 50
19-
# Add some structure to make patterns visible
20-
data[0, :6] += 20 # Sales good first half
21-
data[2, 6:] += 25 # Engineering good second half
22-
data[4, :] = data[4, :] * 0.5 + 60 # Finance stable
23-
24-
# Plot
25-
fig, ax = plt.subplots(figsize=(16, 9))
17+
# Generate performance data (values 0-100)
18+
data = np.random.randn(len(departments), len(months)) * 20 + 50
19+
# Add patterns to demonstrate heatmap capabilities
20+
data[0, :6] += 20 # Sales strong first half
21+
data[2, 6:] += 25 # Engineering strong second half
22+
data[4, :] = data[4, :] * 0.3 + 70 # Finance consistently stable
23+
data[5, 3:9] -= 15 # HR dip mid-year
24+
# Clip to valid performance range
25+
data = np.clip(data, 5, 95)
26+
27+
# Plot - using square format for heatmap
28+
fig, ax = plt.subplots(figsize=(12, 12))
2629
sns.heatmap(
2730
data,
2831
annot=True,
@@ -31,23 +34,25 @@
3134
center=50,
3235
xticklabels=months,
3336
yticklabels=departments,
34-
linewidths=0.5,
37+
linewidths=1,
3538
linecolor="white",
36-
cbar_kws={"label": "Performance Score", "shrink": 0.8},
37-
annot_kws={"fontsize": 14},
39+
cbar_kws={"label": "Performance Score", "shrink": 0.75},
40+
annot_kws={"fontsize": 16},
3841
ax=ax,
42+
vmin=0,
43+
vmax=100,
3944
)
4045

4146
# Style
4247
ax.set_xlabel("Month", fontsize=20)
4348
ax.set_ylabel("Department", fontsize=20)
44-
ax.set_title("heatmap-basic · seaborn · pyplots.ai", fontsize=24)
49+
ax.set_title("heatmap-basic · seaborn · pyplots.ai", fontsize=24, pad=20)
4550
ax.tick_params(axis="both", labelsize=16)
4651

4752
# Adjust colorbar label size
4853
cbar = ax.collections[0].colorbar
4954
cbar.ax.tick_params(labelsize=14)
50-
cbar.ax.set_ylabel("Performance Score", fontsize=16)
55+
cbar.ax.set_ylabel("Performance Score", fontsize=18)
5156

5257
plt.tight_layout()
5358
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
11
library: seaborn
22
specification_id: heatmap-basic
3-
created: 2025-12-14 09:11:58+00:00
4-
updated: 2025-12-14 09:11:58+00:00
3+
created: '2025-12-23T00:46:00Z'
4+
updated: '2025-12-23T00:49:07Z'
55
generated_by: claude-opus-4-5-20251101
6-
workflow_run: 20205724549
7-
issue: 691
6+
workflow_run: 20447949053
7+
issue: 0
88
python_version: 3.13.11
99
library_version: 0.13.2
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/heatmap-basic/seaborn/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/heatmap-basic/seaborn/plot_thumb.png
1212
preview_html: null
13-
quality_score: 94
13+
quality_score: 93
1414
review:
15-
strengths: []
16-
weaknesses: []
17-
improvements: []
15+
strengths:
16+
- Excellent use of diverging RdBu colormap centered at 50, making it easy to distinguish
17+
above/below average performance
18+
- Data patterns are intentionally crafted to demonstrate heatmap capabilities (Sales
19+
strong first half, Engineering strong second half, Finance consistently stable,
20+
HR mid-year dip)
21+
- Cell annotations with appropriate font size (16pt) make exact values readable
22+
without cluttering
23+
- Square figure format (12×12) is perfect for this 7×12 matrix, allowing cells to
24+
be nearly square
25+
- White gridlines with linewidth=1 provide clear cell separation without being distracting
26+
- Colorbar properly configured with shrink, label, and tick formatting
27+
weaknesses:
28+
- Could use sns.clustermap or add dendrograms to showcase seaborn clustering capabilities
29+
as mentioned in spec notes
30+
- Colorbar label is set twice (in cbar_kws and manually), which is redundant code

0 commit comments

Comments
 (0)