Skip to content

Commit b28d1b1

Browse files
fix(seaborn): address review feedback for swarm-basic
Attempt 1/4 - fixes based on AI review
1 parent be4a3bc commit b28d1b1

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

  • plots/swarm-basic/implementations/python

plots/swarm-basic/implementations/python/seaborn.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" anyplot.ai
1+
"""anyplot.ai
22
swarm-basic: Basic Swarm Plot
33
Library: seaborn 0.13.2 | Python 3.13.14
44
Quality: 88/100 | Updated: 2026-07-26
@@ -73,6 +73,24 @@
7373
# Plot — figsize=(8, 4.5) @ dpi=400 → 3200×1800 (see prompts/library/seaborn.md "Canvas")
7474
fig, ax = plt.subplots(figsize=(8, 4.5), dpi=400, facecolor=PAGE_BG)
7575

76+
# Distribution silhouette — subtle violin outline behind each swarm for density
77+
# context beyond the raw points (drawn first so the swarm layers on top)
78+
sns.violinplot(
79+
data=df,
80+
x="Condition",
81+
y="Reaction Time",
82+
hue="Condition",
83+
palette=IMPRINT_PALETTE,
84+
fill=False,
85+
inner=None,
86+
cut=0,
87+
width=0.7,
88+
linewidth=1.3,
89+
alpha=0.35,
90+
legend=False,
91+
ax=ax,
92+
)
93+
7694
sns.swarmplot(
7795
data=df,
7896
x="Condition",
@@ -87,21 +105,26 @@
87105
legend=False,
88106
)
89107

90-
# Median markers — theme-adaptive diamond focal points
108+
# Median markers — hollow diamonds so the focal point reads clearly without
109+
# swallowing the underlying points in dense categories (Distraction, Fatigue)
91110
medians = df.groupby("Condition")["Reaction Time"].median()
92111
for i, condition in enumerate(conditions):
93-
ax.scatter(i, medians[condition], marker="D", s=55, color=INK, edgecolor=PAGE_BG, linewidth=1.2, zorder=10)
94-
ax.scatter([], [], marker="D", s=45, color=INK, edgecolor=PAGE_BG, linewidth=1.2, label="Median")
112+
ax.scatter(i, medians[condition], marker="D", s=70, facecolor="none", edgecolor=INK, linewidth=1.8, zorder=10)
113+
ax.scatter([], [], marker="D", s=55, facecolor="none", edgecolor=INK, linewidth=1.8, label="Median")
95114

96115
# Style
97116
ax.set_xlabel("Experimental Condition", fontsize=10)
98117
ax.set_ylabel("Reaction Time (ms)", fontsize=10)
99118
ax.set_title("swarm-basic · python · seaborn · anyplot.ai", fontsize=12, fontweight="medium")
119+
# Sample size folded into each tick label — quick n context without crowding the plot area
120+
ax.set_xticks(range(len(conditions)))
121+
ax.set_xticklabels([f"{c}\n(n={n})" for c, n in zip(conditions, n_per_condition, strict=True)])
100122
ax.tick_params(axis="both", labelsize=8)
101123
ax.yaxis.grid(True, alpha=0.15, linewidth=0.8)
102124
ax.set_ylim(230, 780)
103125
ax.legend(fontsize=8, loc="upper right")
104126
sns.despine(ax=ax)
127+
fig.tight_layout(pad=1.2)
105128

106129
# Save
107130
plt.savefig(f"plot-{THEME}.png", dpi=400, facecolor=PAGE_BG)

0 commit comments

Comments
 (0)