Skip to content

Commit 9008f4d

Browse files
chore(altair): update quality score 90 and review feedback for heatmap-cohort-retention
1 parent f54bf68 commit 9008f4d

2 files changed

Lines changed: 68 additions & 65 deletions

File tree

plots/heatmap-cohort-retention/implementations/altair.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""pyplots.ai
1+
""" pyplots.ai
22
heatmap-cohort-retention: Cohort Retention Heatmap
33
Library: altair 6.0.0 | Python 3.14.3
4-
Quality: 86/100 | Created: 2026-03-16
4+
Quality: 90/100 | Created: 2026-03-16
55
"""
66

77
import altair as alt

plots/heatmap-cohort-retention/metadata/altair.yaml

Lines changed: 66 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
library: altair
22
specification_id: heatmap-cohort-retention
33
created: '2026-03-16T20:46:10Z'
4-
updated: '2026-03-16T20:50:10Z'
4+
updated: '2026-03-16T21:04:16Z'
55
generated_by: claude-opus-4-5-20251101
66
workflow_run: 23165007983
77
issue: 4570
@@ -10,32 +10,33 @@ library_version: 6.0.0
1010
preview_url: https://storage.googleapis.com/pyplots-images/plots/heatmap-cohort-retention/altair/plot.png
1111
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/heatmap-cohort-retention/altair/plot_thumb.png
1212
preview_html: https://storage.googleapis.com/pyplots-images/plots/heatmap-cohort-retention/altair/plot.html
13-
quality_score: 86
13+
quality_score: 90
1414
review:
1515
strengths:
16-
- Perfect spec compliance — all required features implemented correctly (triangular
17-
shape, cell annotations, cohort sizes, color bar)
18-
- Excellent data quality with realistic SaaS retention patterns and plausible cohort
19-
sizes
20-
- Clean, idiomatic Altair code with good use of layer composition and conditional
21-
encoding
22-
- Smart conditional text coloring (white on dark, dark on light) for readability
16+
- Custom 6-stop sequential palette with sophisticated color progression from light
17+
to dark
18+
- Separate % symbol layer at smaller font size adds typographic polish
19+
- Informative subtitle that communicates the key data insight
20+
- 'Expert-level Altair idioms: conditional text color, layer composition, declarative
21+
encoding'
22+
- Perfect spec compliance with all required features present
23+
- Realistic SaaS retention data with plausible decay patterns
2324
weaknesses:
24-
- Design excellence could be improved — the plot looks like a well-configured default
25-
rather than publication-quality
26-
- No visual emphasis or storytelling to highlight interesting patterns
27-
- Y-axis label font size (15pt) is slightly small relative to other text elements
28-
image_description: 'The plot displays a triangular cohort retention heatmap using
29-
a blue sequential colormap. The title "heatmap-cohort-retention · altair · pyplots.ai"
30-
is centered at the top in large font. The y-axis labeled "Signup Cohort" shows
31-
10 cohorts from "Jan 2024 (n=1,926)" to "Oct 2024 (n=1,266)" with cohort sizes
32-
in parentheses. The x-axis labeled "Months Since Signup" shows "Month 0" through
33-
"Month 9". Each cell contains a retention percentage value displayed in bold text
34-
— white text on darker (high-retention) cells and dark gray text on lighter (low-retention)
35-
cells. The triangular shape is correct: Jan 2024 has all 10 periods while Oct
36-
2024 has only Month 0. Cells are separated by white borders. A vertical color
37-
bar legend on the right shows "Retention %" ranging from 0 to 100. Period 0 is
38-
always 100% (darkest blue), with realistic decay patterns across subsequent months.'
25+
- Chart width is 1400 instead of 1600, resulting in 4200px instead of the ideal
26+
4800px output width
27+
- The % suffix fontSize=10 (30px at 3x) is on the small side
28+
image_description: The plot displays a triangular cohort retention heatmap with
29+
10 monthly cohorts (Jan 2024 through Oct 2024) on the y-axis and months since
30+
signup (Month 0 through Month 9) on the x-axis. The cells use a custom sequential
31+
palette transitioning from light gray/white (low retention) through teals to dark
32+
navy (high retention). Each cell contains a bold retention percentage with a smaller
33+
"%" suffix. The triangular shape is correctly formed — Jan 2024 has all 10 periods
34+
while Oct 2024 has only 1. Cohort sizes (e.g., n=1,926) appear in parentheses
35+
next to each cohort label. A vertical color bar legend ("Retention %") is positioned
36+
on the right. The title reads "heatmap-cohort-retention · altair · pyplots.ai"
37+
with a subtitle "Monthly SaaS user retention — earliest cohorts show strongest
38+
long-term engagement". Cell borders are subtle light gray with rounded corners.
39+
The background is clean white.
3940
criteria_checklist:
4041
visual_quality:
4142
score: 28
@@ -46,64 +47,65 @@ review:
4647
score: 7
4748
max: 8
4849
passed: true
49-
comment: Font sizes explicitly set throughout (title 28, axis titles 22, axis
50-
labels 15-17, cell text 16). Y-axis labels at 15pt slightly small.
50+
comment: All font sizes explicitly set (title=28, axis titles=22, tick labels=17,
51+
cell text=15). The % suffix at fontSize=10 is small but readable.
5152
- id: VQ-02
5253
name: No Overlap
5354
score: 6
5455
max: 6
5556
passed: true
56-
comment: No overlapping text anywhere
57+
comment: No overlapping text. Separate % layer with dx offset avoids collision.
5758
- id: VQ-03
5859
name: Element Visibility
5960
score: 6
6061
max: 6
6162
passed: true
62-
comment: Cells well-sized with clear color differentiation and white borders
63+
comment: Rectangles well-sized with cornerRadius and subtle stroke borders.
6364
- id: VQ-04
6465
name: Color Accessibility
6566
score: 4
6667
max: 4
6768
passed: true
68-
comment: Blues colormap is colorblind-safe with conditional text color for
69-
readability
69+
comment: Sequential teal-to-navy palette is colorblind-safe with good luminance
70+
contrast.
7071
- id: VQ-05
7172
name: Layout & Canvas
7273
score: 3
7374
max: 4
7475
passed: true
75-
comment: Good layout, triangular shape inherently leaves empty space in lower-right
76+
comment: Width=1400 (4200px at 3x) slightly narrower than ideal 4800px. Triangular
77+
shape leaves inherent empty space.
7678
- id: VQ-06
7779
name: Axis Labels & Title
7880
score: 2
7981
max: 2
8082
passed: true
81-
comment: 'Descriptive labels: Months Since Signup, Signup Cohort'
83+
comment: 'Descriptive labels: Months Since Signup, Signup Cohort.'
8284
design_excellence:
83-
score: 11
85+
score: 14
8486
max: 20
8587
items:
8688
- id: DE-01
8789
name: Aesthetic Sophistication
88-
score: 5
90+
score: 6
8991
max: 8
9092
passed: true
91-
comment: Blues colormap well-chosen, white cell borders, conditional text
92-
coloring. Above defaults but not publication-level.
93+
comment: Custom 6-stop gradient palette, rounded cell corners, subtle borders,
94+
separate % layer, informative subtitle.
9395
- id: DE-02
9496
name: Visual Refinement
95-
score: 3
97+
score: 4
9698
max: 6
9799
passed: true
98-
comment: View stroke removed, white cell separators. Some refinement but could
99-
be further polished.
100+
comment: View stroke removed, axis domains/ticks hidden, generous padding,
101+
subtle cell borders.
100102
- id: DE-03
101103
name: Data Storytelling
102-
score: 3
104+
score: 4
103105
max: 6
104106
passed: true
105-
comment: Triangular shape and color gradient guide the eye, but no explicit
106-
focal point or emphasis on key insights.
107+
comment: Subtitle communicates key insight. Color gradient guides the eye.
108+
Triangular shape tells temporal story.
107109
spec_compliance:
108110
score: 15
109111
max: 15
@@ -113,26 +115,26 @@ review:
113115
score: 5
114116
max: 5
115117
passed: true
116-
comment: Correct triangular heatmap
118+
comment: Correct triangular heatmap.
117119
- id: SC-02
118120
name: Required Features
119121
score: 4
120122
max: 4
121123
passed: true
122-
comment: 'All spec features present: triangular shape, cell annotations, cohort
123-
sizes, color bar'
124+
comment: 'All features: triangular shape, retention % in cells, cohort sizes,
125+
colorbar, sequential colormap.'
124126
- id: SC-03
125127
name: Data Mapping
126128
score: 3
127129
max: 3
128130
passed: true
129-
comment: X=periods, Y=cohorts, correct mapping
131+
comment: X=periods, Y=cohorts. All data correctly mapped.
130132
- id: SC-04
131133
name: Title & Legend
132134
score: 3
133135
max: 3
134136
passed: true
135-
comment: Title format correct, color bar legend labeled Retention %
137+
comment: Title format correct. Color bar legend with Retention % label.
136138
data_quality:
137139
score: 15
138140
max: 15
@@ -142,20 +144,20 @@ review:
142144
score: 6
143145
max: 6
144146
passed: true
145-
comment: Full retention decay, cohort variation, triangular shape, period
146-
0 always 100%
147+
comment: Realistic decay, period 0=100%, varying cohort sizes, different retention
148+
curves, full triangular structure.
147149
- id: DQ-02
148150
name: Realistic Context
149151
score: 5
150152
max: 5
151153
passed: true
152-
comment: Realistic SaaS monthly cohort retention with plausible user counts
154+
comment: Monthly SaaS user retention — real, neutral business scenario.
153155
- id: DQ-03
154156
name: Appropriate Scale
155157
score: 4
156158
max: 4
157159
passed: true
158-
comment: Realistic retention values and cohort sizes
160+
comment: Retention decays 100% to ~19.5%. Cohort sizes 921-2438 plausible.
159161
code_quality:
160162
score: 10
161163
max: 10
@@ -165,55 +167,56 @@ review:
165167
score: 3
166168
max: 3
167169
passed: true
168-
comment: 'Clean linear flow: imports, data, chart, save'
170+
comment: 'Clean linear flow: imports, data, layers, combine, save.'
169171
- id: CQ-02
170172
name: Reproducibility
171173
score: 2
172174
max: 2
173175
passed: true
174-
comment: np.random.seed(42) set
176+
comment: np.random.seed(42) set.
175177
- id: CQ-03
176178
name: Clean Imports
177179
score: 2
178180
max: 2
179181
passed: true
180-
comment: All imports used
182+
comment: Only altair, numpy, pandas — all used.
181183
- id: CQ-04
182184
name: Code Elegance
183185
score: 2
184186
max: 2
185187
passed: true
186-
comment: Clean, well-structured, appropriate complexity
188+
comment: Clean three-layer composition. Not over-engineered.
187189
- id: CQ-05
188190
name: Output & API
189191
score: 1
190192
max: 1
191193
passed: true
192-
comment: Saves plot.png with scale_factor=3.0 and plot.html
194+
comment: Saves plot.png and plot.html. Current Altair 6.0 API.
193195
library_mastery:
194-
score: 7
196+
score: 8
195197
max: 10
196198
items:
197199
- id: LM-01
198200
name: Idiomatic Usage
199-
score: 4
201+
score: 5
200202
max: 5
201203
passed: true
202-
comment: 'Good declarative API usage: mark_rect + mark_text layering, proper
203-
encoding types, alt.Scale/Axis'
204+
comment: 'Expert Altair: mark_rect/mark_text, ordinal encoding with sort,
205+
alt.condition, alt.layer, alt.Title, configure_view/axis.'
204206
- id: LM-02
205207
name: Distinctive Features
206208
score: 3
207209
max: 5
208210
passed: true
209-
comment: Uses alt.condition for conditional text coloring, layer composition,
210-
configure_view
211-
verdict: REJECTED
211+
comment: alt.condition for dynamic text color, tooltip interactivity, HTML
212+
export, declarative layer composition.
213+
verdict: APPROVED
212214
impl_tags:
213215
dependencies: []
214216
techniques:
215217
- annotations
216218
- layer-composition
219+
- hover-tooltips
217220
- html-export
218221
patterns:
219222
- data-generation

0 commit comments

Comments
 (0)