Skip to content

Commit 9229ffd

Browse files
feat(matplotlib): implement scatter-categorical (#2604)
## Implementation: `scatter-categorical` - matplotlib Implements the **matplotlib** version of `scatter-categorical`. **File:** `plots/scatter-categorical/implementations/matplotlib.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20594554566)* --------- 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 ec07e0a commit 9229ffd

2 files changed

Lines changed: 105 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+
scatter-categorical: Categorical Scatter Plot
3+
Library: matplotlib 3.10.8 | Python 3.13.11
4+
Quality: 93/100 | Created: 2025-12-30
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
11+
# Data - Iris-like measurements with species categories
12+
np.random.seed(42)
13+
14+
# Generate data for 3 plant species with different characteristics
15+
n_per_group = 40
16+
17+
# Species A: Smaller petals
18+
species_a_x = np.random.normal(1.5, 0.3, n_per_group)
19+
species_a_y = np.random.normal(0.3, 0.1, n_per_group)
20+
21+
# Species B: Medium petals
22+
species_b_x = np.random.normal(4.0, 0.5, n_per_group)
23+
species_b_y = np.random.normal(1.3, 0.2, n_per_group)
24+
25+
# Species C: Larger petals
26+
species_c_x = np.random.normal(5.5, 0.6, n_per_group)
27+
species_c_y = np.random.normal(2.0, 0.3, n_per_group)
28+
29+
# Colors - Python Blue, Python Yellow, and a complementary teal
30+
colors = ["#306998", "#FFD43B", "#2AA198"]
31+
categories = ["Species A", "Species B", "Species C"]
32+
33+
# Plot
34+
fig, ax = plt.subplots(figsize=(16, 9))
35+
36+
# Plot each category with distinct colors and markers
37+
ax.scatter(
38+
species_a_x,
39+
species_a_y,
40+
s=200,
41+
c=colors[0],
42+
alpha=0.8,
43+
label=categories[0],
44+
marker="o",
45+
edgecolors="white",
46+
linewidths=0.5,
47+
)
48+
ax.scatter(
49+
species_b_x,
50+
species_b_y,
51+
s=200,
52+
c=colors[1],
53+
alpha=0.8,
54+
label=categories[1],
55+
marker="s",
56+
edgecolors="#666666",
57+
linewidths=0.5,
58+
)
59+
ax.scatter(
60+
species_c_x,
61+
species_c_y,
62+
s=200,
63+
c=colors[2],
64+
alpha=0.8,
65+
label=categories[2],
66+
marker="^",
67+
edgecolors="white",
68+
linewidths=0.5,
69+
)
70+
71+
# Labels and styling
72+
ax.set_xlabel("Petal Length (cm)", fontsize=20)
73+
ax.set_ylabel("Petal Width (cm)", fontsize=20)
74+
ax.set_title("scatter-categorical · matplotlib · pyplots.ai", fontsize=24)
75+
ax.tick_params(axis="both", labelsize=16)
76+
ax.grid(True, alpha=0.3, linestyle="--")
77+
ax.legend(fontsize=16, loc="upper left", framealpha=0.9)
78+
79+
plt.tight_layout()
80+
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: matplotlib
2+
specification_id: scatter-categorical
3+
created: '2025-12-30T10:37:25Z'
4+
updated: '2025-12-30T10:42:25Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20594554566
7+
issue: 0
8+
python_version: 3.13.11
9+
library_version: 3.10.8
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/scatter-categorical/matplotlib/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/scatter-categorical/matplotlib/plot_thumb.png
12+
preview_html: null
13+
quality_score: 93
14+
review:
15+
strengths:
16+
- Excellent use of different marker shapes (circle, square, triangle) for additional
17+
category distinction beyond color
18+
- Clean, well-organized code following KISS principles
19+
- Realistic Iris-like data scenario that is scientifically relevant and neutral
20+
- White edge colors on markers improve visibility and separation
21+
- Proper font sizing throughout for high-resolution output
22+
weaknesses:
23+
- Library features could be more distinctive - matplotlib offers patheffects, custom
24+
marker paths, or gradient fills that are not utilized
25+
- Yellow markers with white background could have slightly better contrast

0 commit comments

Comments
 (0)