Skip to content

Commit 6fb20ff

Browse files
feat(seaborn): implement violin-box (#2666)
## Implementation: `violin-box` - seaborn Implements the **seaborn** version of `violin-box`. **File:** `plots/violin-box/implementations/seaborn.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20595338490)* --------- 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 847f365 commit 6fb20ff

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
""" pyplots.ai
2+
violin-box: Violin Plot with Embedded Box Plot
3+
Library: seaborn 0.13.2 | Python 3.13.11
4+
Quality: 95/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 varied distributions for each batch to show different shapes
17+
batch_a = np.random.normal(75, 8, 120) # Normal, centered around 75
18+
batch_b = np.concatenate([np.random.normal(60, 5, 60), np.random.normal(80, 5, 60)]) # Bimodal
19+
batch_c = np.random.exponential(10, 120) + 50 # Right-skewed
20+
batch_d = 95 - np.random.exponential(10, 120) # Left-skewed
21+
22+
# Combine into DataFrame
23+
df = pd.DataFrame(
24+
{
25+
"Quality Score": np.concatenate([batch_a, batch_b, batch_c, batch_d]),
26+
"Batch": ["Batch A"] * 120 + ["Batch B"] * 120 + ["Batch C"] * 120 + ["Batch D"] * 120,
27+
}
28+
)
29+
30+
# Create figure
31+
fig, ax = plt.subplots(figsize=(16, 9))
32+
33+
# Create violin plot with embedded box plot using inner='box'
34+
sns.violinplot(
35+
data=df,
36+
x="Batch",
37+
y="Quality Score",
38+
hue="Batch",
39+
palette=["#306998", "#FFD43B", "#4A90A4", "#E8A838"],
40+
inner="box",
41+
linewidth=2,
42+
saturation=0.9,
43+
legend=False,
44+
ax=ax,
45+
)
46+
47+
# Styling
48+
ax.set_title("violin-box · seaborn · pyplots.ai", fontsize=24, fontweight="bold", pad=20)
49+
ax.set_xlabel("Manufacturing Batch", fontsize=20)
50+
ax.set_ylabel("Quality Score (0-100)", fontsize=20)
51+
ax.tick_params(axis="both", labelsize=16)
52+
ax.grid(True, alpha=0.3, linestyle="--", axis="y")
53+
54+
# Set y-axis limits for better visibility
55+
ax.set_ylim(30, 100)
56+
57+
plt.tight_layout()
58+
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
library: seaborn
2+
specification_id: violin-box
3+
created: '2025-12-30T11:22:35Z'
4+
updated: '2025-12-30T11:31:26Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20595338490
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/violin-box/seaborn/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/violin-box/seaborn/plot_thumb.png
12+
preview_html: null
13+
quality_score: 95
14+
review:
15+
strengths:
16+
- Excellent data design showing four distinct distribution shapes (normal, bimodal,
17+
right-skewed, left-skewed) that perfectly demonstrate the value of violin plots
18+
- Clean use of seaborn inner=box parameter for embedded box plots
19+
- Modern API usage with hue parameter to avoid deprecation warnings
20+
- Professional color palette with good contrast and accessibility
21+
- Appropriate font sizes and clear labeling with units
22+
weaknesses:
23+
- Grid only on y-axis, though acceptable for categorical x-axis
24+
- Legend disabled which is fine since batch names are on x-axis, but a small legend
25+
could enhance standalone viewing

0 commit comments

Comments
 (0)