Skip to content

Commit 555aae6

Browse files
chore(altair): update quality score 82 and review feedback for sankey-basic
1 parent 0a4f54d commit 555aae6

2 files changed

Lines changed: 78 additions & 112 deletions

File tree

plots/sankey-basic/implementations/python/altair.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" anyplot.ai
22
sankey-basic: Basic Sankey Diagram
33
Library: altair 6.1.0 | Python 3.13.13
4-
Quality: 85/100 | Updated: 2026-04-30
4+
Quality: 82/100 | Updated: 2026-04-30
55
"""
66

77
import os

plots/sankey-basic/metadata/python/altair.yaml

Lines changed: 77 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ library: altair
22
language: python
33
specification_id: sankey-basic
44
created: '2025-12-23T19:50:52Z'
5-
updated: '2026-04-30T09:06:47Z'
5+
updated: '2026-04-30T09:24:49Z'
66
generated_by: claude-sonnet
77
workflow_run: 25156438466
88
issue: 810
@@ -12,137 +12,113 @@ preview_url_light: https://storage.googleapis.com/anyplot-images/plots/sankey-ba
1212
preview_url_dark: https://storage.googleapis.com/anyplot-images/plots/sankey-basic/python/altair/plot-dark.png
1313
preview_html_light: https://storage.googleapis.com/anyplot-images/plots/sankey-basic/python/altair/plot-light.html
1414
preview_html_dark: https://storage.googleapis.com/anyplot-images/plots/sankey-basic/python/altair/plot-dark.html
15-
quality_score: 85
15+
quality_score: 82
1616
review:
1717
strengths:
18-
- Custom Sankey implementation in Altair (no native Sankey support) using smooth
19-
bezier/smoothstep curves — technically impressive
20-
- 'Source node colors follow Okabe-Ito canonical order: Coal=#009E73, Gas=#D55E00,
21-
Nuclear=#0072B2, Renewable=#CC79A7'
22-
- 'Both renders are fully theme-adaptive with correct backgrounds (#FAF8F1 light
23-
/ #1A1A17 dark) and readable text in both themes'
24-
- All font sizes explicitly set (title=28px, subtitle=20px, node labels=20px bold,
25-
legend title=18px, legend labels=16px)
26-
- 'Correct title format: ''sankey-basic · altair · anyplot.ai'' with descriptive
27-
subtitle'
28-
- Interactive tooltips on nodes and HTML export alongside PNG — leverages Altair's
29-
interactive capabilities
30-
- Realistic energy flow domain (Coal/Gas/Nuclear/Renewable → Residential/Commercial/Industrial/Transport)
31-
with plausible values
32-
- Layer composition with alt.layer() is idiomatic Altair; detail encoding correctly
33-
groups flow polygons per source-target pair
18+
- Correct Okabe-Ito palette (positions 1-4) for source node and flow colors
19+
- Smooth smoothstep bezier S-curves create a professional Sankey appearance
20+
- Theme-adaptive chrome (background, text, legend) works correctly in both light
21+
and dark renders with no dark-on-dark failures
22+
- Complete spec compliance including correct title format and interactive HTML export
23+
- Clean, deterministic, readable code with no functions or classes
24+
- Tooltips on nodes provide interactive value information
3425
weaknesses:
35-
- 'Target node colors (#7EC8C8, #A8D8A8, #E8C07A, #C8A8E8) are custom hexes not
36-
in Okabe-Ito palette — use Okabe-Ito positions 5–7 (#E69F00, #56B4E9, #F0E442)
37-
and adaptive neutral for the 4 target nodes'
38-
- No visual emphasis or storytelling — the dominant flow (Coal→Industrial, value=45)
39-
is the single largest flow but receives no special treatment; no focal point guides
40-
the viewer
41-
- 'Node ordering creates maximum crossing: sorting source/target nodes to minimize
42-
crossings would improve readability'
43-
- Top-gap between subtitle and diagram is slightly large (top_margin=100 creates
44-
visible dead space under the subtitle text); compact layout would better utilize
45-
canvas
46-
- 'DE-03 is default (data displayed, no hierarchy): adding subtle emphasis to the
47-
largest flow or highlighting one key insight would elevate storytelling'
26+
- Transport label clipped at bottom canvas edge — only 'T' visible; increase bottom_margin
27+
from 60 to 100 or reduce height scale factor from 0.85 to 0.80
28+
- 'Target node colors are custom hex values (#7EC8C8, #A8D8A8, #E8C07A, #C8A8E8)
29+
not from the Okabe-Ito palette; replace with positions 5-7 (#E69F00, #56B4E9,
30+
#F0E442) plus adaptive neutral'
31+
- Legend shows line symbols (colored dashes) for what are actually filled area marks;
32+
consider a custom legend solution
4833
image_description: |-
4934
Light render (plot-light.png):
50-
Background: Warm off-white (#FAF8F1) correct, not pure white.
51-
Chrome: Title "sankey-basic · altair · anyplot.ai" in bold dark text; subtitle "Energy Flow from Sources to Sectors" in dark-gray. All text clearly readable against the light background. Node labels (Renewable, Nuclear, Gas, Coal on left; Transport, Industrial, Commercial, Residential on right) are 20px bold dark text — fully readable.
52-
Data: Source nodes colored Okabe-Ito canonical order: Coal (#009E73 green-teal, bottom-left), Gas (#D55E00 orange, middle-left), Nuclear (#0072B2 blue, upper-middle-left), Renewable (#CC79A7 pink-purple, top-left). Flow bands inherit source colors with opacity=0.55. Target nodes use custom colors: Residential=teal, Commercial=light-green, Industrial=warm-tan, Transport=light-purple. Legend box (bottom-right) shows "Energy Source" with correct color swatches. Significant flow crossing visible in the center (X-pattern) — inherent to full mesh of 4 sources × 4 targets.
53-
Legibility verdict: PASS — all text dark on off-white, no contrast failures.
35+
Background: Warm off-white (#FAF8F1) - correct
36+
Chrome: Title "sankey-basic · altair · anyplot.ai" (28px, dark ink) and subtitle "Energy Flow from Sources to Sectors" (20px) are clearly readable. Node labels for Coal, Nuclear, Gas, Renewable (left), Industrial, Commercial, Residential (right) are readable in dark ink at 20px bold. Legend text readable at 16px. ISSUE: Transport target label is clipped - only "T" is visible at the bottom-right canvas edge.
37+
Data: Four sources use Okabe-Ito positions 1-4: Coal=#009E73 (green), Gas=#D55E00 (vermillion), Nuclear=#0072B2 (blue), Renewable=#CC79A7 (pink-purple). Flow bands are semi-transparent (opacity=0.55) colored by source. Target node colors (#7EC8C8, #A8D8A8, #E8C07A, #C8A8E8) are custom non-Okabe-Ito values. Smooth S-curves connect sources to targets.
38+
Legibility verdict: PASS (with caveat: Transport label clipped to "T")
5439
5540
Dark render (plot-dark.png):
56-
Background: Near-black (#1A1A17) correct, not pure black.
57-
Chrome: Title and subtitle in light/white text — readable. Node labels in light (#F0EFE8) text — no dark-on-dark failures detected. Legend box has dark elevated background (#242420) with light-colored text.
58-
Data: Data colors are the same underlying hex values as light render (theme-constant). Due to opacity=0.55 alpha-blending on flow bands, colors appear visually darker/more saturated against the dark background (expected blending behavior). Node rectangles remain clearly visible with INK_SOFT borders. Flow crossing pattern identical to light render.
59-
Legibility verdict: PASS — all text is light on dark, no dark-on-dark failures.
41+
Background: Near-black (#1A1A17) - correct
42+
Chrome: Title and subtitle rendered in light ink (#F0EFE8), clearly readable against dark background. Node labels rendered in INK token (light) - readable for all visible nodes. Legend box uses elevated dark fill (#242420) with subtle border. No dark-on-dark failures for any visible text elements.
43+
Data: Flow band colors are identical to light render - Coal=#009E73, Gas=#D55E00, Nuclear=#0072B2, Renewable=#CC79A7. Data colors unchanged, only chrome flips between themes. Same Transport label clipping issue persists.
44+
Legibility verdict: PASS (with caveat: Transport label clipped to "T", same as light render)
6045
criteria_checklist:
6146
visual_quality:
62-
score: 27
47+
score: 24
6348
max: 30
6449
items:
6550
- id: VQ-01
6651
name: Text Legibility
67-
score: 8
52+
score: 7
6853
max: 8
6954
passed: true
70-
comment: 'All font sizes explicitly set: title=28px, subtitle=20px, node labels=20px
71-
bold, legend title=18px, legend labels=16px. Readable in both themes.'
55+
comment: Font sizes excellent (title 28, labels 20, legend 16); Transport
56+
label clipped to 'T'
7257
- id: VQ-02
7358
name: No Overlap
74-
score: 6
59+
score: 5
7560
max: 6
7661
passed: true
77-
comment: No overlapping text. Source and target labels positioned outside
78-
the crossing flow area. Legend well-placed.
62+
comment: Labels well-spaced; Transport truncation counts as partial failure
7963
- id: VQ-03
8064
name: Element Visibility
8165
score: 5
8266
max: 6
8367
passed: true
84-
comment: All elements visible. Flow bands opacity=0.55 appropriate for crossing
85-
flows. Individual flow tracing is difficult due to the X-crossing pattern,
86-
but this is inherent to the full-mesh Sankey layout.
68+
comment: All flows visible at opacity=0.55; Transport node very small but
69+
present
8770
- id: VQ-04
8871
name: Color Accessibility
8972
score: 2
9073
max: 2
9174
passed: true
92-
comment: Okabe-Ito source colors are CVD-safe. Flow bands distinguishable
93-
by hue + position.
75+
comment: Okabe-Ito for sources; labels provide text identification
9476
- id: VQ-05
9577
name: Layout & Canvas
96-
score: 3
78+
score: 2
9779
max: 4
98-
passed: true
99-
comment: Diagram fills ~80% of canvas horizontally and ~75% vertically. Slight
100-
dead-space gap between subtitle and diagram start due to top_margin=100.
80+
passed: false
81+
comment: Transport node partially clipped at bottom canvas edge; label shows
82+
only 'T'
10183
- id: VQ-06
10284
name: Axis Labels & Title
10385
score: 2
10486
max: 2
10587
passed: true
106-
comment: Correct title format. Node names serve as labels. Subtitle describes
107-
the flow context. No traditional axes needed for Sankey.
88+
comment: Correct title format; descriptive subtitle; axes hidden appropriately
10889
- id: VQ-07
10990
name: Palette Compliance
11091
score: 1
11192
max: 2
11293
passed: false
113-
comment: 'Source flow colors follow Okabe-Ito canonical order (Coal=#009E73,
114-
Gas=#D55E00, Nuclear=#0072B2, Renewable=#CC79A7). However, target node colors
115-
(#7EC8C8, #A8D8A8, #E8C07A, #C8A8E8) are custom hexes not in Okabe-Ito palette.
116-
Both backgrounds are theme-correct. Partial compliance.'
94+
comment: 'Source colors use Okabe-Ito positions 1-4 correctly. Target node
95+
colors (#7EC8C8, #A8D8A8, #E8C07A, #C8A8E8) are custom hex values not from
96+
Okabe-Ito'
11797
design_excellence:
118-
score: 11
98+
score: 12
11999
max: 20
120100
items:
121101
- id: DE-01
122102
name: Aesthetic Sophistication
123103
score: 5
124104
max: 8
125105
passed: true
126-
comment: Above generic default — building a full Sankey from scratch in Altair
127-
demonstrates thoughtful implementation. Good color scheme for sources. Target
128-
node custom colors reduce coherence. Not publication-ready.
106+
comment: Professional manual Sankey via Altair primitives; smooth bezier S-curves;
107+
styled legend
129108
- id: DE-02
130109
name: Visual Refinement
131110
score: 4
132111
max: 6
133112
passed: true
134-
comment: No grid lines (appropriate), no spines, smooth bezier curves, opacity-blended
135-
flows, node borders with INK_SOFT. Good refinement above defaults but top
136-
gap reduces polish.
113+
comment: No axes/spines appropriate; no grid; clean background; good node
114+
padding
137115
- id: DE-03
138116
name: Data Storytelling
139-
score: 2
117+
score: 3
140118
max: 6
141-
passed: false
142-
comment: Data displayed correctly but no visual hierarchy or emphasis. The
143-
largest single flow (Coal→Industrial, value=45) is not highlighted. Crossing
144-
node order creates a maximally complex visual without guiding the viewer
145-
to any insight.
119+
passed: true
120+
comment: Clear energy source->sector flow narrative; width encoding communicates
121+
magnitudes; no explicit emphasis on dominant pathways
146122
spec_compliance:
147123
score: 15
148124
max: 15
@@ -152,54 +128,51 @@ review:
152128
score: 5
153129
max: 5
154130
passed: true
155-
comment: Correct Sankey diagram with proportional flow band widths and smooth
156-
curves.
131+
comment: Correct Sankey diagram with nodes and proportional flow bands
157132
- id: SC-02
158133
name: Required Features
159134
score: 4
160135
max: 4
161136
passed: true
162-
comment: Source nodes, target nodes, proportional values, distinct source
163-
colors, link opacity for crossings — all present.
137+
comment: Source nodes, target nodes, proportional widths, distinct source
138+
colors, link opacity, no circular flows
164139
- id: SC-03
165140
name: Data Mapping
166141
score: 3
167142
max: 3
168143
passed: true
169-
comment: All 12 flows correctly represented. Band widths proportional to values.
170-
All nodes visible.
144+
comment: Energy flow sources to sectors; values mapped to band widths
171145
- id: SC-04
172146
name: Title & Legend
173147
score: 3
174148
max: 3
175149
passed: true
176-
comment: 'Title: ''sankey-basic · altair · anyplot.ai'' correct. Legend shows
177-
Energy Source with correct Okabe-Ito color swatches.'
150+
comment: Title matches spec-id·library·anyplot.ai format; legend labels match
151+
source categories
178152
data_quality:
179-
score: 15
153+
score: 14
180154
max: 15
181155
items:
182156
- id: DQ-01
183157
name: Feature Coverage
184-
score: 6
158+
score: 5
185159
max: 6
186160
passed: true
187-
comment: 'Shows all Sankey aspects: multiple sources, multiple targets, varying
188-
flow magnitudes, crossing flows, proportional node heights.'
161+
comment: 12 flows across 4x4 source/target grid; Transport only receives one
162+
flow limiting full coverage
189163
- id: DQ-02
190164
name: Realistic Context
191165
score: 5
192166
max: 5
193167
passed: true
194-
comment: Real-world energy flow scenario (Coal/Gas/Nuclear/Renewable → Residential/Commercial/Industrial/Transport).
195-
Neutral domain.
168+
comment: Energy distribution domain realistic and neutral; Coal->Industrial
169+
largest is plausible
196170
- id: DQ-03
197171
name: Appropriate Scale
198172
score: 4
199173
max: 4
200174
passed: true
201-
comment: Values 10–45 units. Coal→Industrial (45) being the dominant industrial
202-
flow is realistic. Proportions plausible for energy sector distribution.
175+
comment: 12 flows within 5-50 recommended range; values 10-45 sensible
203176
code_quality:
204177
score: 10
205178
max: 10
@@ -209,36 +182,32 @@ review:
209182
score: 3
210183
max: 3
211184
passed: true
212-
comment: 'Linear structure: imports → data → geometry computation → chart
213-
layers → save. No functions or classes.'
185+
comment: No functions or classes; clean procedural flow
214186
- id: CQ-02
215187
name: Reproducibility
216188
score: 2
217189
max: 2
218190
passed: true
219-
comment: Fully deterministic — all data is hardcoded, no random generation
220-
needed.
191+
comment: No random elements; fully deterministic
221192
- id: CQ-03
222193
name: Clean Imports
223194
score: 2
224195
max: 2
225196
passed: true
226-
comment: Only os, altair, pandas imported and all are used.
197+
comment: Only os, altair, pandas - all used
227198
- id: CQ-04
228199
name: Code Elegance
229200
score: 2
230201
max: 2
231202
passed: true
232-
comment: The bezier geometry computation (~100 lines) is appropriate complexity
233-
for a custom Sankey in a library with no native Sankey support. No fake
234-
UI elements.
203+
comment: Complexity justified by manual Sankey construction; no fake UI
235204
- id: CQ-05
236205
name: Output & API
237206
score: 1
238207
max: 1
239208
passed: true
240-
comment: Saves plot-{THEME}.png (scale_factor=3.0) and plot-{THEME}.html.
241-
Correct altair API.
209+
comment: Saves plot-{THEME}.png (scale_factor=3.0) and plot-{THEME}.html;
210+
current Altair 6.x API
242211
library_mastery:
243212
score: 7
244213
max: 10
@@ -248,29 +217,26 @@ review:
248217
score: 4
249218
max: 5
250219
passed: true
251-
comment: Uses alt.layer() composition, detail encoding for flow grouping,
252-
mark_line(filled=True) for polygon fills, mark_rect for nodes, mark_text
253-
for labels — all idiomatic Altair patterns.
220+
comment: Correct alt.layer() composition, proper encoding types (Q/N), alt.Title
221+
with subtitle, configure_legend/configure_view
254222
- id: LM-02
255223
name: Distinctive Features
256224
score: 3
257225
max: 5
258226
passed: true
259-
comment: detail:N encoding for grouping polygon paths, alt.layer() multi-layer
260-
composition, interactive tooltips on nodes, dual PNG+HTML output — several
261-
Altair-distinctive features leveraged.
262-
verdict: REJECTED
227+
comment: Interactive HTML export, node tooltips, layer composition of primitive
228+
marks to build custom chart type
229+
verdict: APPROVED
263230
impl_tags:
264231
dependencies: []
265232
techniques:
266-
- html-export
267233
- layer-composition
268-
- hover-tooltips
269234
- bezier-curves
235+
- hover-tooltips
236+
- html-export
270237
patterns:
271-
- data-generation
238+
- groupby-aggregation
272239
- iteration-over-groups
273240
dataprep: []
274241
styling:
275242
- alpha-blending
276-
- minimal-chrome

0 commit comments

Comments
 (0)