Skip to content

Commit f9f7b2c

Browse files
update(bullet-basic): seaborn — comprehensive quality review
Comprehensive quality review improving library feature usage, visual design, and data quality.
1 parent 1e072e3 commit f9f7b2c

2 files changed

Lines changed: 48 additions & 46 deletions

File tree

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
""" pyplots.ai
1+
"""pyplots.ai
22
bullet-basic: Basic Bullet Chart
3-
Library: seaborn 0.13.2 | Python 3.13.11
4-
Quality: 92/100 | Created: 2025-12-23
3+
Library: seaborn 0.13.2 | Python 3.14.3
4+
Quality: /100 | Updated: 2026-02-22
55
"""
66

77
import matplotlib.patches as mpatches
88
import matplotlib.pyplot as plt
9-
import numpy as np
109
import pandas as pd
1110
import seaborn as sns
1211

1312

1413
# Data - Multiple KPIs with actual values, targets, and qualitative ranges
15-
np.random.seed(42)
16-
1714
metrics = ["Revenue", "Customer\nSatisfaction", "Efficiency", "Quality\nScore"]
18-
actuals = [78, 85, 62, 91]
15+
actuals = [78, 85, 35, 91]
1916
targets = [90, 80, 75, 85]
2017
# Ranges define thresholds for qualitative bands (poor/satisfactory/good)
2118
ranges_list = [
@@ -25,41 +22,51 @@
2522
[70, 85, 100], # Quality Score
2623
]
2724

28-
# Create figure
29-
fig, ax = plt.subplots(figsize=(16, 9))
30-
sns.set_style("whitegrid")
31-
32-
# Qualitative range colors (grayscale as per specification - dark to light for poor to good)
33-
range_colors = ["#e0e0e0", "#bdbdbd", "#8c8c8c"]
34-
35-
# Bar dimensions
36-
range_height = 0.7
37-
actual_height = 0.35
38-
n_metrics = len(metrics)
39-
y_positions = np.arange(n_metrics)
40-
41-
# Draw qualitative ranges as background bands for each metric
42-
for y_pos, ranges in zip(y_positions, ranges_list, strict=True):
25+
# Build a long-form DataFrame for qualitative range bands
26+
range_labels = ["Good", "Satisfactory", "Poor"]
27+
range_records = []
28+
for metric, ranges in zip(metrics, ranges_list, strict=True):
4329
prev = 0
44-
for end, color in zip(ranges, range_colors, strict=True):
45-
width = end - prev
46-
ax.barh(y_pos, width, left=prev, height=range_height, color=color, edgecolor="none", zorder=1)
30+
for end, label in zip(ranges, range_labels[::-1], strict=True):
31+
range_records.append({"Metric": metric, "Range": label, "Start": prev, "Width": end - prev})
4732
prev = end
33+
df_ranges = pd.DataFrame(range_records)
34+
35+
# Seaborn grayscale palette for qualitative bands (dark=poor, medium=satisfactory, light=good)
36+
band_palette = dict(zip(range_labels, sns.light_palette("#555555", n_colors=4, reverse=True)[1:], strict=True))
37+
38+
# Create figure with seaborn theme
39+
sns.set_theme(style="whitegrid", rc={"axes.spines.top": False, "axes.spines.right": False, "axes.spines.left": False})
40+
fig, ax = plt.subplots(figsize=(16, 9))
4841

49-
# Create DataFrame for seaborn barplot
50-
df = pd.DataFrame({"Metric": metrics, "Actual": actuals})
42+
# Draw qualitative range bands using seaborn barplot layering
43+
range_height = 0.7
44+
for label in range_labels:
45+
subset = df_ranges[df_ranges["Range"] == label]
46+
sns.barplot(
47+
data=subset,
48+
x="Width",
49+
y="Metric",
50+
color=band_palette[label],
51+
left=subset["Start"].values,
52+
width=range_height,
53+
edgecolor="none",
54+
ax=ax,
55+
zorder=1,
56+
)
5157

52-
# Draw actual value bars using seaborn
58+
# Actual value bars using seaborn barplot
59+
df_actual = pd.DataFrame({"Metric": metrics, "Actual": actuals})
5360
sns.barplot(
54-
data=df,
61+
data=df_actual,
5562
x="Actual",
5663
y="Metric",
57-
color="#306998", # Python Blue
58-
width=actual_height,
59-
ax=ax,
60-
zorder=3,
64+
color="#306998",
65+
width=0.35,
6166
edgecolor="#1e4d6b",
6267
linewidth=1.5,
68+
ax=ax,
69+
zorder=3,
6370
)
6471

6572
# Draw target markers as vertical lines
@@ -92,18 +99,13 @@
9299

93100
# Create legend
94101
legend_elements = [
95-
mpatches.Patch(facecolor=range_colors[0], label="Poor"),
96-
mpatches.Patch(facecolor=range_colors[1], label="Satisfactory"),
97-
mpatches.Patch(facecolor=range_colors[2], label="Good"),
102+
mpatches.Patch(facecolor=band_palette["Poor"], label="Poor"),
103+
mpatches.Patch(facecolor=band_palette["Satisfactory"], label="Satisfactory"),
104+
mpatches.Patch(facecolor=band_palette["Good"], label="Good"),
98105
mpatches.Patch(facecolor="#306998", edgecolor="#1e4d6b", linewidth=1.5, label="Actual"),
99106
plt.Line2D([0], [0], color="#1a1a1a", linewidth=5, label="Target"),
100107
]
101-
ax.legend(handles=legend_elements, loc="upper right", fontsize=14, framealpha=0.95)
102-
103-
# Remove spines for cleaner look
104-
ax.spines["top"].set_visible(False)
105-
ax.spines["right"].set_visible(False)
106-
ax.spines["left"].set_visible(False)
108+
ax.legend(handles=legend_elements, loc="upper right", fontsize=13, framealpha=0.95)
107109

108110
plt.tight_layout()
109111
plt.savefig("plot.png", dpi=300, bbox_inches="tight")

plots/bullet-basic/metadata/seaborn.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
library: seaborn
22
specification_id: bullet-basic
33
created: '2025-12-23T09:20:31Z'
4-
updated: '2025-12-23T09:24:02Z'
5-
generated_by: claude-opus-4-5-20251101
4+
updated: '2026-02-22T12:00:00+00:00'
5+
generated_by: claude-opus-4-6
66
workflow_run: 20456603775
77
issue: 0
8-
python_version: 3.13.11
8+
python_version: 3.14.3
99
library_version: 0.13.2
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/bullet-basic/seaborn/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/bullet-basic/seaborn/plot_thumb.png
1212
preview_html: null
13-
quality_score: 92
13+
quality_score: null
1414
impl_tags:
1515
dependencies: []
1616
techniques:

0 commit comments

Comments
 (0)