Skip to content

Commit dcb7386

Browse files
feat(seaborn): implement cat-box-strip (#2735)
## Implementation: `cat-box-strip` - seaborn Implements the **seaborn** version of `cat-box-strip`. **File:** `plots/cat-box-strip/implementations/seaborn.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20601055897)* --------- 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 263e16a commit dcb7386

2 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
""" pyplots.ai
2+
cat-box-strip: Box Plot with Strip Overlay
3+
Library: seaborn 0.13.2 | Python 3.13.11
4+
Quality: 92/100 | Created: 2025-12-30
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
import pandas as pd
10+
import seaborn as sns
11+
12+
13+
# Data - product quality scores across manufacturing batches
14+
np.random.seed(42)
15+
16+
# Create groups with different distributions to show boxplot features
17+
batch_a = np.random.normal(75, 8, 40) # Centered, moderate spread
18+
batch_b = np.random.normal(82, 5, 35) # Higher center, tight spread
19+
batch_c = np.concatenate(
20+
[
21+
np.random.normal(68, 6, 30), # Main distribution
22+
[45, 48, 95, 97], # Outliers
23+
]
24+
)
25+
batch_d = np.random.normal(70, 12, 45) # Wide spread
26+
27+
# Combine into DataFrame
28+
df = pd.DataFrame(
29+
{
30+
"Batch": ["Batch A"] * len(batch_a)
31+
+ ["Batch B"] * len(batch_b)
32+
+ ["Batch C"] * len(batch_c)
33+
+ ["Batch D"] * len(batch_d),
34+
"Quality Score": np.concatenate([batch_a, batch_b, batch_c, batch_d]),
35+
}
36+
)
37+
38+
# Create plot
39+
fig, ax = plt.subplots(figsize=(16, 9))
40+
41+
# Box plot with boxes in Python Blue
42+
sns.boxplot(
43+
data=df,
44+
x="Batch",
45+
y="Quality Score",
46+
hue="Batch",
47+
palette=["#306998"] * 4,
48+
width=0.5,
49+
linewidth=2,
50+
fliersize=0, # Hide box plot outliers (strip will show them)
51+
legend=False,
52+
ax=ax,
53+
)
54+
55+
# Strip plot overlay with Python Yellow
56+
sns.stripplot(
57+
data=df,
58+
x="Batch",
59+
y="Quality Score",
60+
color="#FFD43B",
61+
size=10,
62+
alpha=0.7,
63+
jitter=0.2,
64+
edgecolor="#333333",
65+
linewidth=0.5,
66+
ax=ax,
67+
)
68+
69+
# Styling
70+
ax.set_title("cat-box-strip · seaborn · pyplots.ai", fontsize=24)
71+
ax.set_xlabel("Manufacturing Batch", fontsize=20)
72+
ax.set_ylabel("Quality Score (points)", fontsize=20)
73+
ax.tick_params(axis="both", labelsize=16)
74+
ax.grid(True, axis="y", alpha=0.3, linestyle="--")
75+
76+
# Set y-axis limits with some padding
77+
ax.set_ylim(35, 105)
78+
79+
plt.tight_layout()
80+
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: seaborn
2+
specification_id: cat-box-strip
3+
created: '2025-12-30T16:28:36Z'
4+
updated: '2025-12-30T16:54:19Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20601055897
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/cat-box-strip/seaborn/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/cat-box-strip/seaborn/plot_thumb.png
12+
preview_html: null
13+
quality_score: 92
14+
review:
15+
strengths:
16+
- Excellent data design showing varied distributions (different medians, spreads,
17+
and outliers) that demonstrate all boxplot features
18+
- Clean visual hierarchy with Python Blue boxes and contrasting Yellow strip points
19+
- Proper use of modern seaborn API (hue parameter with palette, legend=False)
20+
- Smart handling of outliers by hiding boxplot fliers (fliersize=0) since strip
21+
plot shows all points
22+
- Good jitter (0.2) and alpha (0.7) settings for strip points to show density without
23+
excessive overlap
24+
- Realistic manufacturing quality scenario with appropriate value ranges
25+
weaknesses:
26+
- Grid styling could include both x and y axes for complete reference (minor)

0 commit comments

Comments
 (0)