Skip to content

Commit daf83ab

Browse files
feat(makie): implement bar-stacked-labeled (#10802)
## Implementation: `bar-stacked-labeled` - julia/makie Implements the **julia/makie** version of `bar-stacked-labeled`. **File:** `plots/bar-stacked-labeled/implementations/julia/makie.jl` **Parent Issue:** #3504 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/anyplot/actions/runs/33002350165)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
1 parent 61c9f13 commit daf83ab

2 files changed

Lines changed: 355 additions & 0 deletions

File tree

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# anyplot.ai
2+
# bar-stacked-labeled: Stacked Bar Chart with Total Labels
3+
# Library: makie 0.21.9 | Julia 1.11.9
4+
# Quality: 90/100 | Created: 2026-08-26
5+
6+
using CairoMakie
7+
using Colors
8+
9+
# --- Theme tokens -----------------------------------------------------------
10+
const THEME = get(ENV, "ANYPLOT_THEME", "light")
11+
const PAGE_BG = THEME == "light" ? colorant"#FAF8F1" : colorant"#1A1A17"
12+
const INK = THEME == "light" ? colorant"#1A1A17" : colorant"#F0EFE8"
13+
const INK_SOFT = THEME == "light" ? colorant"#4A4A44" : colorant"#B8B7B0"
14+
15+
const IMPRINT_PALETTE = [
16+
colorant"#009E73", colorant"#C475FD", colorant"#4467A3", colorant"#BD8233",
17+
colorant"#AE3030", colorant"#2ABCCD", colorant"#954477", colorant"#99B314",
18+
]
19+
20+
# --- Data -------------------------------------------------------------------
21+
# Quarterly SaaS revenue split by product line ($M, illustrative).
22+
quarters = ["Q1", "Q2", "Q3", "Q4"]
23+
product_lines = ["Subscriptions", "Services", "Hardware", "Support"]
24+
25+
revenue = [
26+
5.2 2.1 0.9 0.5
27+
5.8 2.3 0.8 0.5
28+
6.5 2.6 0.9 0.6
29+
7.3 3.0 0.9 0.7
30+
]
31+
32+
n_quarter = length(quarters)
33+
n_product = length(product_lines)
34+
35+
x = repeat(1:n_quarter, inner = n_product)
36+
stack = repeat(1:n_product, outer = n_quarter)
37+
height = vec(permutedims(revenue))
38+
39+
totals = vec(sum(revenue, dims = 2))
40+
41+
# --- Plot ---------------------------------------------------------------
42+
fig = Figure(
43+
size = (1600, 900),
44+
fontsize = 14,
45+
backgroundcolor = PAGE_BG,
46+
)
47+
48+
ax = Axis(
49+
fig[1, 1];
50+
title = "bar-stacked-labeled · julia · makie · anyplot.ai",
51+
titlesize = 20,
52+
titlecolor = INK,
53+
xlabel = "Quarter",
54+
ylabel = "Revenue (\$M)",
55+
xlabelsize = 14,
56+
ylabelsize = 14,
57+
xlabelcolor = INK,
58+
ylabelcolor = INK,
59+
xticklabelsize = 13,
60+
yticklabelsize = 12,
61+
xticklabelcolor = INK_SOFT,
62+
yticklabelcolor = INK_SOFT,
63+
xtickcolor = INK_SOFT,
64+
ytickcolor = INK_SOFT,
65+
backgroundcolor = PAGE_BG,
66+
topspinevisible = false,
67+
rightspinevisible = false,
68+
leftspinecolor = INK_SOFT,
69+
bottomspinecolor = INK_SOFT,
70+
xgridvisible = false,
71+
ygridvisible = true,
72+
ygridcolor = RGBAf(INK.r, INK.g, INK.b, 0.12),
73+
yminorgridvisible = false,
74+
)
75+
76+
barplot!(
77+
ax, x, height;
78+
stack = stack,
79+
color = stack,
80+
colormap = IMPRINT_PALETTE[1:n_product],
81+
width = 0.6,
82+
strokewidth = 0,
83+
)
84+
85+
ax.xticks = (1:n_quarter, quarters)
86+
87+
# --- Total labels: genuinely bold and larger than any other text, directly
88+
# above the tallest segment of each stack. `rich()` mixes weight/size within
89+
# one label -- the dollar figure is bold and oversized, the trailing "M"
90+
# unit is smaller and softer, echoing typographic hierarchy from financial
91+
# dashboards.
92+
for (i, total) in enumerate(totals)
93+
text!(
94+
ax, Point2f(i, total);
95+
text = rich(
96+
rich("\$$(round(total, digits = 1))"; font = :bold, fontsize = 19, color = INK),
97+
rich("M"; fontsize = 14, color = INK_SOFT),
98+
),
99+
offset = (0, 8),
100+
align = (:center, :bottom),
101+
)
102+
end
103+
104+
Legend(
105+
fig[1, 2], [PolyElement(color = c) for c in IMPRINT_PALETTE[1:n_product]], product_lines;
106+
labelcolor = INK_SOFT,
107+
labelsize = 13,
108+
framevisible = false,
109+
backgroundcolor = PAGE_BG,
110+
)
111+
112+
# Fix the y-range last so the label headroom above the tallest bar survives
113+
# any autolimits reset triggered by the legend/text calls above.
114+
ylims!(ax, 0, maximum(totals) * 1.16)
115+
116+
# --- Save ---------------------------------------------------------------
117+
save("plot-$(THEME).png", fig; px_per_unit = 2)
Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
library: makie
2+
language: julia
3+
specification_id: bar-stacked-labeled
4+
created: '2026-08-26T18:59:57Z'
5+
updated: '2026-08-26T19:37:54Z'
6+
generated_by: claude-sonnet
7+
workflow_run: 33002350165
8+
issue: 3504
9+
language_version: 1.11.9
10+
library_version: 0.21.9
11+
preview_url_light: https://storage.googleapis.com/anyplot-images/plots/bar-stacked-labeled/julia/makie/plot-light.png
12+
preview_url_dark: https://storage.googleapis.com/anyplot-images/plots/bar-stacked-labeled/julia/makie/plot-dark.png
13+
preview_html_light: null
14+
preview_html_dark: null
15+
quality_score: 90
16+
review:
17+
strengths:
18+
- 'Pixel-verified: canvas is exactly 3200x1800, and data colors are identical between
19+
light and dark renders — only chrome flips, as required'
20+
- Total labels use genuine typographic hierarchy (rich() bold-oversized value +
21+
smaller/softer unit) rather than uniform text, directly serving the spec's 'eliminate
22+
mental arithmetic' goal
23+
- Clean, idiomatic use of Makie's native stack= keyword on barplot! rather than
24+
manually cumsum-ing segment heights
25+
- ylims! is set last with explicit headroom (max(totals) * 1.16) specifically to
26+
protect label space from being clobbered by autolimits
27+
weaknesses:
28+
- 'Title is disproportionately small: measured at only ~30% of the plot/axis width
29+
(849px / 2814px) against the style guide''s ~50-70% target for this canvas size.
30+
Increase titlesize from 20 toward ~26-28 so the mandated title carries appropriate
31+
visual weight on the 3200x1800 landscape canvas.'
32+
- Y-axis has only two gridlines (5 and 10) across a 0-~13.8 range — slightly sparse
33+
for reading intermediate values off the chart.
34+
image_description: |-
35+
Light render (plot-light.png):
36+
Background: Warm off-white, matches #FAF8F1 target — not pure white, not dark.
37+
Chrome: Title "bar-stacked-labeled · julia · makie · anyplot.ai" centered in dark ink, clearly readable but measured at only ~30% of the plot width (undersized relative to the ~50-70% target). Axis labels ("Quarter" / "Revenue ($M)") and tick labels are dark/soft-ink and legible. Legend at right (Subscriptions/Services/Hardware/Support) is frameless, blends with background, text legible. Total labels ($8.7M, $9.4M, $10.6M, $11.9M) bold and clearly visible above each stack.
38+
Data: Four stacked segments per bar — Subscriptions #009E73 (bottom), Services #C475FD, Hardware #4467A3, Support #BD8233 (top). First series confirmed #009E73.
39+
Legibility verdict: PASS (title is legible but proportionally small — flagged as a VQ-05 weakness, not a legibility failure)
40+
41+
Dark render (plot-dark.png):
42+
Background: Warm near-black, matches #1A1A17 target — not pure black, not light.
43+
Chrome: Title, axis labels, tick labels, legend text, and total labels all flip to light ink (#F0EFE8 / #B8B7B0) and are clearly visible against the dark background. No dark-on-dark failures observed anywhere.
44+
Data: Same four segment colors as the light render, pixel-consistent — only chrome (background/text/grid/legend) changed between themes as required.
45+
Legibility verdict: PASS
46+
criteria_checklist:
47+
visual_quality:
48+
score: 28
49+
max: 30
50+
items:
51+
- id: VQ-01
52+
name: Text Legibility
53+
score: 7
54+
max: 8
55+
passed: true
56+
comment: All chrome and total labels legible in both themes; title is legible
57+
but noticeably undersized
58+
- id: VQ-02
59+
name: No Overlap
60+
score: 6
61+
max: 6
62+
passed: true
63+
comment: No collisions between total labels, gridlines, legend, or bars
64+
- id: VQ-03
65+
name: Element Visibility
66+
score: 6
67+
max: 6
68+
passed: true
69+
comment: Bar segments and colors clearly distinguishable at this data density
70+
- id: VQ-04
71+
name: Color Accessibility
72+
score: 2
73+
max: 2
74+
passed: true
75+
comment: Imprint palette provides adequate hue separation, no red-green-only
76+
encoding
77+
- id: VQ-05
78+
name: Layout & Canvas
79+
score: 3
80+
max: 4
81+
passed: true
82+
comment: Title spans only ~30% of plot width vs ~50-70% target; nothing clipped,
83+
canvas exactly 3200x1800
84+
- id: VQ-06
85+
name: Axis Labels & Title
86+
score: 2
87+
max: 2
88+
passed: true
89+
comment: Revenue ($M) includes units, Quarter is descriptive
90+
- id: VQ-07
91+
name: Palette Compliance
92+
score: 2
93+
max: 2
94+
passed: true
95+
comment: 'First series #009E73, canonical Imprint order, correct theme backgrounds,
96+
identical data colors across themes'
97+
design_excellence:
98+
score: 13
99+
max: 20
100+
items:
101+
- id: DE-01
102+
name: Aesthetic Sophistication
103+
score: 5
104+
max: 8
105+
passed: true
106+
comment: Typographic hierarchy in total labels via rich(), custom palette;
107+
undercut by undersized title
108+
- id: DE-02
109+
name: Visual Refinement
110+
score: 4
111+
max: 6
112+
passed: true
113+
comment: Spines removed, y-only subtle grid, generous whitespace, frameless
114+
legend
115+
- id: DE-03
116+
name: Data Storytelling
117+
score: 4
118+
max: 6
119+
passed: true
120+
comment: Bold total labels create a clear focal point showing the quarter-over-quarter
121+
growth trend
122+
spec_compliance:
123+
score: 15
124+
max: 15
125+
items:
126+
- id: SC-01
127+
name: Plot Type
128+
score: 5
129+
max: 5
130+
passed: true
131+
comment: Correct stacked bar chart
132+
- id: SC-02
133+
name: Required Features
134+
score: 4
135+
max: 4
136+
passed: true
137+
comment: Total labels above stacks, consistent format, adequate headroom via
138+
ylims!
139+
- id: SC-03
140+
name: Data Mapping
141+
score: 3
142+
max: 3
143+
passed: true
144+
comment: X=quarter, Y=stacked revenue by component, all data visible
145+
- id: SC-04
146+
name: Title & Legend
147+
score: 3
148+
max: 3
149+
passed: true
150+
comment: Title matches required format; legend labels match and are ordered
151+
to match stack
152+
data_quality:
153+
score: 15
154+
max: 15
155+
items:
156+
- id: DQ-01
157+
name: Feature Coverage
158+
score: 6
159+
max: 6
160+
passed: true
161+
comment: Categories, stacked components, and computed totals all shown
162+
- id: DQ-02
163+
name: Realistic Context
164+
score: 5
165+
max: 5
166+
passed: true
167+
comment: Quarterly SaaS revenue by product line, plausible and neutral
168+
- id: DQ-03
169+
name: Appropriate Scale
170+
score: 4
171+
max: 4
172+
passed: true
173+
comment: $0.5M-$7.3M segments, $8.7M-$11.9M totals with believable growth
174+
code_quality:
175+
score: 10
176+
max: 10
177+
items:
178+
- id: CQ-01
179+
name: KISS Structure
180+
score: 3
181+
max: 3
182+
passed: true
183+
comment: Flat script, no functions/classes
184+
- id: CQ-02
185+
name: Reproducibility
186+
score: 2
187+
max: 2
188+
passed: true
189+
comment: Fully deterministic hardcoded data
190+
- id: CQ-03
191+
name: Clean Imports
192+
score: 2
193+
max: 2
194+
passed: true
195+
comment: Only CairoMakie and Colors, both used
196+
- id: CQ-04
197+
name: Code Elegance
198+
score: 2
199+
max: 2
200+
passed: true
201+
comment: Appropriately concise, no fake UI
202+
- id: CQ-05
203+
name: Output & API
204+
score: 1
205+
max: 1
206+
passed: true
207+
comment: Saves plot-$(THEME).png via current save API
208+
library_mastery:
209+
score: 9
210+
max: 10
211+
items:
212+
- id: LM-01
213+
name: Idiomatic Usage
214+
score: 5
215+
max: 5
216+
passed: true
217+
comment: Native barplot! stack=/color=/colormap= keywords, high-level Axis/Legend
218+
grammar
219+
- id: LM-02
220+
name: Distinctive Features
221+
score: 4
222+
max: 5
223+
passed: false
224+
comment: rich() mixed-weight text is Makie-specific; no other distinctive
225+
capability exercised
226+
verdict: APPROVED
227+
impl_tags:
228+
dependencies: []
229+
techniques:
230+
- annotations
231+
- custom-legend
232+
patterns:
233+
- matrix-construction
234+
- iteration-over-groups
235+
dataprep: []
236+
styling:
237+
- grid-styling
238+
- publication-ready

0 commit comments

Comments
 (0)