Skip to content

Commit be73d61

Browse files
chore(altair): update quality score 88 and review feedback for dendrogram-basic
1 parent c127f4b commit be73d61

2 files changed

Lines changed: 78 additions & 72 deletions

File tree

plots/dendrogram-basic/implementations/altair.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
"""pyplots.ai
1+
""" pyplots.ai
22
dendrogram-basic: Basic Dendrogram
33
Library: altair 6.0.0 | Python 3.14.3
4+
Quality: 88/100 | Updated: 2026-04-05
45
"""
56

67
import altair as alt
Lines changed: 76 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
library: altair
22
specification_id: dendrogram-basic
33
created: '2025-12-23T10:01:58Z'
4-
updated: '2026-04-05T21:01:34Z'
4+
updated: '2026-04-05T21:11:24Z'
55
generated_by: claude-opus-4-6
66
workflow_run: 20457533018
77
issue: 0
88
python_version: 3.14.3
99
library_version: 6.0.0
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/dendrogram-basic/altair/plot.png
1111
preview_html: https://storage.googleapis.com/pyplots-images/plots/dendrogram-basic/altair/plot.html
12-
quality_score: 87
12+
quality_score: 88
1313
impl_tags:
1414
dependencies:
1515
- scipy
1616
- sklearn
1717
techniques:
18-
- hover-tooltips
18+
- annotations
1919
- layer-composition
20+
- hover-tooltips
2021
- custom-legend
2122
- html-export
2223
patterns:
@@ -29,103 +30,102 @@ impl_tags:
2930
- edge-highlighting
3031
review:
3132
strengths:
32-
- Excellent cluster-based branch coloring that propagates through the linkage hierarchy
33-
— makes species groupings immediately visible
34-
- Interactive legend selection (click to highlight species) leverages Altair declarative
35-
interactivity
36-
- Threshold reference line with annotation adds interpretive context
37-
- Clean, well-structured code that handles the complexity of building a dendrogram
38-
from scratch in Altair
39-
- Real Iris dataset provides meaningful, neutral scientific context
33+
- Excellent data storytelling with annotation, subtitle, and threshold line communicating
34+
the Setosa separation insight
35+
- Cluster-colored branches add meaningful visual encoding beyond basic dendrogram
36+
- Interactive legend selection is a genuinely useful Altair-specific feature
37+
- Clean, well-structured code handling dendrogram construction from scratch in Altair
38+
- Refined visual styling with subtle grid, removed view borders, and polished legend
4039
weaknesses:
41-
- Leaf label font size (13pt) is slightly small for the canvas dimensions — could
42-
be 15-16pt
43-
- Design could push further with background color, more dramatic spine treatment,
44-
or annotation of key merge points
45-
- Some lower-distance merges have very short line segments that are harder to distinguish
46-
image_description: 'The plot displays a dendrogram of 15 iris flower samples clustered
47-
using Ward''s linkage method. The tree structure shows branches colored by cluster
48-
membership: blue (#306998) for Setosa (5 samples on the left), gold (#D4A017)
49-
for Versicolor (5 samples in the middle), and purple (#7B68AE) for Virginica (5
50-
samples on the right). Gray branches appear where mixed clusters merge at the
51-
top (~10.3 distance). A dashed red horizontal line at distance 5.0 marks the cluster
52-
threshold, labeled "cluster threshold" in italic red text. Leaf labels are rotated
53-
~315 degrees at the bottom, colored by species, with filled circular markers at
54-
each leaf position. A subtitle reads "Ward''s linkage on Iris measurements — Setosa
55-
separates clearly from Versicolor/Virginica". The y-axis shows "Distance (Ward''s
56-
method)" from 0 to 12. A legend on the right identifies the three species with
57-
colored dots. The overall layout is clean with subtle grid lines and no axis frame.'
40+
- Rotated leaf labels at 315 degrees are somewhat crowded, especially for longer
41+
labels like Virginica-140
42+
- Minor empty space on the left side of the canvas
43+
image_description: 'The plot displays a dendrogram of 15 Iris flower samples (5
44+
each of Setosa, Versicolor, Virginica) clustered using Ward''s linkage method.
45+
The Y-axis shows "Distance (Ward''s method)" ranging from 0 to approximately 12.
46+
Branches are colored by cluster membership: blue (#306998) for Setosa, gold (#D4A017)
47+
for Versicolor, purple (#7B68AE) for Virginica, and gray (#888888) for inter-cluster
48+
merges. A dashed red threshold line at d=5.0 is labeled "cluster threshold (d
49+
= 5.0)". Leaf labels are rotated 315 degrees at the base with colored circular
50+
dots by species. A legend titled "Species" sits in the upper right corner with
51+
a subtle border. The title reads "dendrogram-basic · altair · pyplots.ai" with
52+
a subtitle "Ward''s linkage on Iris measurements — Setosa separates clearly from
53+
Versicolor / Virginica". An annotation at the top merge point reads "Setosa diverges
54+
from Versicolor + Virginica" with a small triangle arrow. Background is light
55+
gray (#FAFBFC) with subtle dashed gridlines.'
5856
criteria_checklist:
5957
visual_quality:
60-
score: 27
58+
score: 25
6159
max: 30
6260
items:
6361
- id: VQ-01
6462
name: Text Legibility
6563
score: 7
6664
max: 8
6765
passed: true
68-
comment: Title 28pt, axis labels 18pt, axis title 22pt excellent. Leaf labels
69-
at 13pt slightly small but readable.
66+
comment: All font sizes explicitly set (title 28, subtitle 18, axis 18/22,
67+
leaf 16, legend 18/16). Annotation and threshold labels at 14pt slightly
68+
small but readable.
7069
- id: VQ-02
7170
name: No Overlap
72-
score: 5
71+
score: 4
7372
max: 6
7473
passed: true
75-
comment: Leaf labels well-spaced with rotation. Minor tightness between some
76-
adjacent labels.
74+
comment: Rotated leaf labels at 315 degrees somewhat crowded; longer labels
75+
like Virginica-140 are tight against neighbors.
7776
- id: VQ-03
7877
name: Element Visibility
7978
score: 5
8079
max: 6
8180
passed: true
82-
comment: Branch lines at strokeWidth=2.5 clearly visible. Leaf dots distinctive.
83-
Some short low-distance segments less prominent.
81+
comment: Branch lines (strokeWidth=3) and leaf dots (size=180) clearly visible.
82+
Good density for 15 items.
8483
- id: VQ-04
8584
name: Color Accessibility
8685
score: 4
8786
max: 4
8887
passed: true
89-
comment: Blue/gold/purple palette is colorblind-safe with good luminance contrast.
88+
comment: Blue/gold/purple palette is colorblind-safe with strong contrast.
89+
Gray for inter-cluster merges is distinguishable.
9090
- id: VQ-05
9191
name: Layout & Canvas
92-
score: 4
92+
score: 3
9393
max: 4
9494
passed: true
95-
comment: Plot fills canvas well at 1600x900. Legend positioned cleanly. Balanced
96-
margins.
95+
comment: Good canvas utilization. Some empty space on far left. Legend well-positioned.
9796
- id: VQ-06
9897
name: Axis Labels & Title
9998
score: 2
10099
max: 2
101100
passed: true
102-
comment: Y-axis labeled Distance (Ward's method). X-axis appropriately unlabeled
103-
for dendrogram.
101+
comment: Y-axis reads Distance (Ward's method) - descriptive with method.
102+
X-axis correctly hidden.
104103
design_excellence:
105-
score: 14
104+
score: 16
106105
max: 20
107106
items:
108107
- id: DE-01
109108
name: Aesthetic Sophistication
110109
score: 6
111110
max: 8
112111
passed: true
113-
comment: Custom palette, cluster-based branch coloring, threshold line, subtitle
114-
narrative. Above defaults.
112+
comment: Custom palette with Python Blue, refined legend styling, custom background,
113+
cluster-colored branches. Clearly above defaults.
115114
- id: DE-02
116115
name: Visual Refinement
117-
score: 4
116+
score: 5
118117
max: 6
119118
passed: true
120-
comment: View stroke removed, subtle grid, custom legend styling. Good but
121-
could push further.
119+
comment: View stroke removed, subtle grid (opacity 0.12, dashed), refined
120+
domain/tick colors, generous legend padding.
122121
- id: DE-03
123122
name: Data Storytelling
124-
score: 4
123+
score: 5
125124
max: 6
126125
passed: true
127-
comment: Subtitle communicates key insight. Cluster coloring and threshold
128-
line guide interpretation.
126+
comment: Subtitle states key insight, annotation highlights top merge, threshold
127+
line contextualizes clusters, branch colors reinforce identity. Interactive
128+
legend adds exploration.
129129
spec_compliance:
130130
score: 15
131131
max: 15
@@ -135,26 +135,27 @@ review:
135135
score: 5
136136
max: 5
137137
passed: true
138-
comment: Correct dendrogram showing hierarchical clustering.
138+
comment: Correct dendrogram with hierarchical tree structure.
139139
- id: SC-02
140140
name: Required Features
141141
score: 4
142142
max: 4
143143
passed: true
144-
comment: All spec features present plus bonus threshold line and species coloring.
144+
comment: 'All spec features present: hierarchical clustering, labeled leaves,
145+
proportional branch heights, vertical orientation.'
145146
- id: SC-03
146147
name: Data Mapping
147148
score: 3
148149
max: 3
149150
passed: true
150-
comment: X from scipy dendrogram layout, Y from computed distances. All 15
151-
samples visible.
151+
comment: Y-axis correctly maps merge distances, leaf positions follow scipy
152+
dendrogram layout.
152153
- id: SC-04
153154
name: Title & Legend
154155
score: 3
155156
max: 3
156157
passed: true
157-
comment: Title matches required format. Legend correctly labels species.
158+
comment: Title format correct. Species legend with matching labels and colors.
158159
data_quality:
159160
score: 14
160161
max: 15
@@ -164,20 +165,22 @@ review:
164165
score: 5
165166
max: 6
166167
passed: true
167-
comment: Multiple merge levels, clear species separation, varying within-cluster
168-
distances.
168+
comment: Shows clear cluster separation, varying merge distances, within and
169+
between-cluster merges.
169170
- id: DQ-02
170171
name: Realistic Context
171172
score: 5
172173
max: 5
173174
passed: true
174-
comment: Classic Iris dataset - real, well-known, neutral scientific data.
175+
comment: Iris dataset is a classic real-world scientific dataset. Neutral
176+
and well-known.
175177
- id: DQ-03
176178
name: Appropriate Scale
177179
score: 4
178180
max: 4
179181
passed: true
180-
comment: 15 samples from Iris with real computed Ward distances.
182+
comment: 15 samples with realistic Euclidean distances. Ward's method produces
183+
sensible merge heights.
181184
code_quality:
182185
score: 10
183186
max: 10
@@ -187,47 +190,49 @@ review:
187190
score: 3
188191
max: 3
189192
passed: true
190-
comment: 'Linear flow: imports, data, clustering, segments, chart, save. No
191-
functions/classes.'
193+
comment: 'Clean linear flow: imports, data, clustering, segments, chart layers,
194+
save.'
192195
- id: CQ-02
193196
name: Reproducibility
194197
score: 2
195198
max: 2
196199
passed: true
197-
comment: Deterministic data from specific Iris indices.
200+
comment: Deterministic data from Iris dataset with fixed sample indices.
198201
- id: CQ-03
199202
name: Clean Imports
200203
score: 2
201204
max: 2
202205
passed: true
203-
comment: All imports used.
206+
comment: 'All imports used: altair, pandas, scipy.cluster.hierarchy, sklearn.datasets.'
204207
- id: CQ-04
205208
name: Code Elegance
206209
score: 2
207210
max: 2
208211
passed: true
209-
comment: Necessarily complex for building dendrogram in Altair. Well-commented.
212+
comment: Well-structured segment extraction, clean layer composition. Appropriate
213+
complexity.
210214
- id: CQ-05
211215
name: Output & API
212216
score: 1
213217
max: 1
214218
passed: true
215-
comment: Saves as plot.png and plot.html.
219+
comment: Saves as plot.png (scale_factor=3.0) and plot.html. Current API.
216220
library_mastery:
217-
score: 7
221+
score: 8
218222
max: 10
219223
items:
220224
- id: LM-01
221225
name: Idiomatic Usage
222226
score: 4
223227
max: 5
224228
passed: true
225-
comment: Good layered composition, mark_rule for lines, proper encoding types.
229+
comment: 'Good declarative grammar usage: mark_rule, mark_point, mark_text,
230+
alt.layer, alt.Title, configure_* methods.'
226231
- id: LM-02
227232
name: Distinctive Features
228-
score: 3
233+
score: 4
229234
max: 5
230235
passed: true
231-
comment: Interactive legend selection, tooltips, HTML export are distinctly
232-
Altair features.
236+
comment: Interactive selection_point with legend binding, tooltips, HTML export,
237+
conditional opacity encoding.
233238
verdict: REJECTED

0 commit comments

Comments
 (0)