Skip to content

Commit b8d5302

Browse files
fix(seaborn): address review feedback for heatmap-basic
Attempt 1/3 - fixes based on AI review
1 parent 9fedde2 commit b8d5302

1 file changed

Lines changed: 30 additions & 16 deletions

File tree

plots/heatmap-basic/implementations/seaborn.py

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
heatmap-basic: Basic Heatmap
33
Library: seaborn 0.13.2 | Python 3.14.3
44
Quality: 82/100 | Updated: 2026-02-15
@@ -25,38 +25,52 @@
2525
data = np.clip(data, 5, 95)
2626

2727
# Plot - clustermap groups similar departments via hierarchical clustering
28-
cmap = sns.diverging_palette(240, 10, as_cmap=True)
2928
g = sns.clustermap(
3029
data,
3130
annot=True,
3231
fmt=".0f",
33-
cmap=cmap,
32+
cmap="coolwarm",
3433
center=50,
3534
xticklabels=months,
3635
yticklabels=departments,
37-
linewidths=1,
36+
linewidths=1.5,
3837
linecolor="white",
39-
annot_kws={"fontsize": 14},
38+
annot_kws={"fontsize": 16, "fontweight": "medium"},
4039
figsize=(16, 10),
4140
row_cluster=True,
4241
col_cluster=False,
4342
dendrogram_ratio=0.08,
44-
cbar_pos=None,
43+
cbar_pos=(0.02, 0.15, 0.03, 0.6),
44+
cbar_kws={"label": "Performance Score", "ticks": [0, 25, 50, 75, 100]},
4545
vmin=0,
4646
vmax=100,
4747
)
4848

49-
# Colorbar with proper placement
50-
sm = plt.cm.ScalarMappable(cmap=cmap, norm=plt.Normalize(0, 100))
51-
cbar = g.fig.colorbar(sm, ax=g.ax_heatmap, location="right", shrink=0.7, pad=0.12)
52-
cbar.set_label("Performance Score", fontsize=18)
53-
cbar.ax.tick_params(labelsize=14)
49+
# Colorbar styling
50+
g.cax.set_ylabel("Performance Score", fontsize=18, labelpad=10)
51+
g.cax.tick_params(labelsize=14)
52+
g.cax.yaxis.set_label_position("left")
5453

55-
# Style
56-
g.ax_heatmap.set_xlabel("Month", fontsize=20)
57-
g.ax_heatmap.set_ylabel("")
54+
# Labels and title
55+
g.ax_heatmap.set_xlabel("Month", fontsize=20, labelpad=12)
56+
g.ax_heatmap.set_ylabel("Department", fontsize=20, labelpad=12)
5857
g.ax_heatmap.tick_params(axis="x", labelsize=16)
5958
g.ax_heatmap.tick_params(axis="y", labelsize=16, rotation=0)
60-
g.fig.suptitle("heatmap-basic · seaborn · pyplots.ai", fontsize=24, y=1.02)
6159

62-
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
60+
# Visual refinement - remove heatmap spines for cleaner look
61+
for spine in g.ax_heatmap.spines.values():
62+
spine.set_visible(False)
63+
64+
# Style the dendrogram
65+
g.ax_row_dendrogram.set_facecolor("#f8f8f8")
66+
for spine in g.ax_row_dendrogram.spines.values():
67+
spine.set_visible(False)
68+
69+
# Background refinement
70+
g.fig.patch.set_facecolor("#fafafa")
71+
g.ax_heatmap.set_facecolor("white")
72+
73+
# Title
74+
g.fig.suptitle("heatmap-basic · seaborn · pyplots.ai", fontsize=24, fontweight="medium", y=1.02, color="#333333")
75+
76+
plt.savefig("plot.png", dpi=300, bbox_inches="tight", facecolor=g.fig.get_facecolor())

0 commit comments

Comments
 (0)