Skip to content

Commit d9c81fa

Browse files
feat(matplotlib): implement point-basic (#2578)
## Implementation: `point-basic` - matplotlib Implements the **matplotlib** version of `point-basic`. **File:** `plots/point-basic/implementations/matplotlib.py` --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20593348785)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e35a521 commit d9c81fa

2 files changed

Lines changed: 102 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
""" pyplots.ai
2+
point-basic: Point Estimate Plot
3+
Library: matplotlib 3.10.8 | Python 3.13.11
4+
Quality: 99/100 | Created: 2025-12-30
5+
"""
6+
7+
import matplotlib.pyplot as plt
8+
import numpy as np
9+
10+
11+
# Data - Customer satisfaction scores by department with 95% confidence intervals
12+
np.random.seed(42)
13+
14+
departments = ["Customer Service", "Technical Support", "Sales", "Billing", "Shipping", "Product Quality", "Returns"]
15+
16+
# Simulated mean satisfaction scores (1-10 scale) with varying confidence intervals
17+
estimates = np.array([7.8, 6.2, 7.1, 5.4, 8.3, 6.9, 5.8])
18+
# Different CI widths show varying sample sizes/uncertainty
19+
ci_lower = np.array([7.2, 5.4, 6.5, 4.6, 7.9, 6.2, 5.1])
20+
ci_upper = np.array([8.4, 7.0, 7.7, 6.2, 8.7, 7.6, 6.5])
21+
22+
# Calculate errors for errorbar (asymmetric)
23+
lower_errors = estimates - ci_lower
24+
upper_errors = ci_upper - estimates
25+
26+
# Plot
27+
fig, ax = plt.subplots(figsize=(16, 9))
28+
29+
# Create horizontal point estimate plot with error bars
30+
y_positions = np.arange(len(departments))
31+
32+
ax.errorbar(
33+
estimates,
34+
y_positions,
35+
xerr=[lower_errors, upper_errors],
36+
fmt="o",
37+
color="#306998",
38+
markersize=14,
39+
markeredgecolor="white",
40+
markeredgewidth=2,
41+
capsize=8,
42+
capthick=2.5,
43+
elinewidth=2.5,
44+
ecolor="#306998",
45+
)
46+
47+
# Add reference line at overall mean
48+
overall_mean = np.mean(estimates)
49+
ax.axvline(x=overall_mean, color="#FFD43B", linestyle="--", linewidth=2.5, alpha=0.8)
50+
ax.text(
51+
overall_mean + 0.05,
52+
len(departments) - 0.3,
53+
f"Overall Mean: {overall_mean:.1f}",
54+
fontsize=16,
55+
color="#B8860B",
56+
fontweight="bold",
57+
)
58+
59+
# Styling
60+
ax.set_yticks(y_positions)
61+
ax.set_yticklabels(departments)
62+
ax.set_xlabel("Satisfaction Score (1-10)", fontsize=20)
63+
ax.set_ylabel("Department", fontsize=20)
64+
ax.set_title("point-basic \u00b7 matplotlib \u00b7 pyplots.ai", fontsize=24)
65+
ax.tick_params(axis="both", labelsize=16)
66+
67+
# Set x-axis limits with padding
68+
ax.set_xlim(3.5, 9.5)
69+
ax.set_ylim(-0.5, len(departments) - 0.5)
70+
71+
# Grid - subtle horizontal lines
72+
ax.grid(True, axis="x", alpha=0.3, linestyle="--")
73+
ax.set_axisbelow(True)
74+
75+
# Invert y-axis so first category is at top
76+
ax.invert_yaxis()
77+
78+
plt.tight_layout()
79+
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
library: matplotlib
2+
specification_id: point-basic
3+
created: '2025-12-30T09:32:00Z'
4+
updated: '2025-12-30T09:42:17Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20593348785
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/point-basic/matplotlib/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/point-basic/matplotlib/plot_thumb.png
12+
preview_html: null
13+
quality_score: 99
14+
review:
15+
strengths:
16+
- Excellent horizontal layout following spec recommendation for readable category
17+
labels
18+
- Clear visual hierarchy with well-sized markers and error bar caps
19+
- Reference line adds valuable context (overall mean) as suggested in spec
20+
- Varying confidence interval widths demonstrate real-world uncertainty patterns
21+
- Clean, professional appearance suitable for publication
22+
weaknesses:
23+
- Could add alpha transparency to markers for even better visual distinction (minor)

0 commit comments

Comments
 (0)