Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plots/marimekko-basic/implementations/python/plotnine.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
""" pyplots.ai
""" anyplot.ai
marimekko-basic: Basic Marimekko Chart
Library: plotnine 0.15.2 | Python 3.13.11
Quality: 92/100 | Created: 2025-12-23
Library: plotnine 0.15.3 | Python 3.14.4
Quality: 78/100 | Updated: 2026-04-29
"""

import pandas as pd
Expand Down
293 changes: 168 additions & 125 deletions plots/marimekko-basic/metadata/python/plotnine.yaml
Original file line number Diff line number Diff line change
@@ -1,164 +1,186 @@
library: plotnine
language: python
specification_id: marimekko-basic
created: '2025-12-23T15:14:07Z'
updated: '2025-12-23T15:19:42Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20464356200
issue: 0
python_version: 3.13.11
library_version: 0.15.2
preview_url: https://storage.googleapis.com/anyplot-images/plots/marimekko-basic/plotnine/plot.png
preview_html: null
quality_score: 92
impl_tags:
dependencies: []
techniques:
- annotations
patterns:
- data-generation
- iteration-over-groups
- long-to-wide
dataprep: []
styling: []
updated: '2026-04-29T11:22:05Z'
generated_by: claude-sonnet
workflow_run: 24974896581
issue: 1002
python_version: 3.14.4
library_version: 0.15.3
preview_url_light: https://storage.googleapis.com/anyplot-images/plots/marimekko-basic/python/plotnine/plot-light.png
preview_url_dark: https://storage.googleapis.com/anyplot-images/plots/marimekko-basic/python/plotnine/plot-dark.png
preview_html_light: null
preview_html_dark: null
quality_score: 78
review:
strengths:
- Excellent implementation of variable-width stacked bars using geom_rect with precise
coordinate calculations
- Clean, readable code with well-documented data transformation logic
- Professional appearance with white borders between segments enhancing visual separation
- Smart conditional labeling showing values only on segments >10% for readability
- Proper use of plotnine grammar of graphics (aes, scales, themes)
- Correct and idiomatic Marimekko construction using geom_rect() with aesthetic
mappings for x/y bounds
- Threshold-based value labeling (>10% segments only) prevents cluttered small-segment
labels
- Realistic market-share data with meaningful regional variation in both widths
and proportional composition
- Clean KISS code structure with all transformations (groupby, cumsum for x/y positions)
clearly laid out
weaknesses:
- Grid lines on y-axis could use alpha transparency for subtler appearance
- Legend is sorted alphabetically rather than matching the stacking order in the
bars
image_description: The plot displays a Marimekko chart showing market share by region
and product line. Four regions (Asia Pacific, Europe, Latin America, North America)
are shown as variable-width stacked bars where width represents total market size.
Each bar is divided into four product categories (Electronics in dark blue, Hardware
in coral/red, Services in teal, Software in yellow). The bars have white borders
between segments. Value labels (e.g., "$200M", "$140M") appear on larger segments.
The y-axis shows percentage (0%-100%), x-axis shows region names centered under
each bar. A legend on the right identifies the four product lines. The title follows
the required format with spec-id, library, and pyplots.ai branding.
- 'Non-Okabe-Ito palette: #306998 (Python Blue) and custom hexes. Replace with Okabe-Ito:
Electronics=#009E73, Software=#D55E00, Services=#0072B2, Hardware=#CC79A7'
- 'No theme adaptation: Code must read os.getenv(''ANYPLOT_THEME'', ''light'') and
apply PAGE_BG, ELEVATED_BG, INK, INK_SOFT tokens to plot_background, panel_background,
axis_text, axis_title, plot_title, legend_background, legend_text, legend_title'
- 'Wrong output filename: plot.save(''plot.png'') must become plot.save(f''plot-{THEME}.png'',
dpi=300, width=16, height=9)'
- 'Wrong URL in title: ''pyplots.ai'' must be ''anyplot.ai'''
- 'Hardcoded label color: geom_text(..., color=''black'') is unreadable on dark
backgrounds; use INK token'
- legend_text=14pt should be 16pt per the style guide
image_description: |-
Light render (plot-light.png):
Background: Near-white, approximately #FAF8F1 or close (hard to distinguish from pure white visually)
Chrome: Title 'Market Share by Region · marimekko-basic · plotnine · anyplot.ai' bold and large — READABLE. Subtitle 'Asia Pacific leads in Electronics revenue ($200M — 53% of its regional market)' visible in muted smaller text — READABLE. Axis labels 'Market Segment (width = total market size)' and 'Product Share (%)' clearly visible. Tick labels (region names and percentage values) all readable. Legend 'Product Line' with colored boxes readable.
Data: Four variable-width Marimekko bars for Asia Pacific, Europe, Latin America, North America. Segments colored: Electronics=teal/blue, Software=medium blue, Services=orange, Hardware=pink. White borders separate segments. Value labels ($200M, $180M, etc.) inside larger segments.
Legibility verdict: PASS

Dark render (plot-dark.png):
Background: Dark near-black, approximately #1A1A17 or close
Chrome: Title text is light/white — READABLE. Subtitle text is light — READABLE. Axis labels are light-colored — READABLE. Tick labels appear light against dark background — READABLE. Legend text is light — READABLE. No dark-on-dark failures observed in the rendered image. NOTE: the theme adaptation visible in the images does NOT appear to be implemented in the current code (no ANYPLOT_THEME env-var read); images appear to be from a previous code revision with theme support. Current code saves to 'plot.png' using theme_minimal() without theme tokens — if re-run from current code, dark mode would produce dark text on dark background (failure).
Data: Segment colors appear identical to light render (same teal, blue, orange, pink hues) — Okabe-Ito data colors should be theme-invariant but these are custom hexes anyway.
Legibility verdict: PASS (images only — code would FAIL if re-run)
criteria_checklist:
visual_quality:
score: 36
max: 40
score: 25
max: 30
items:
- id: VQ-01
name: Text Legibility
score: 10
max: 10
score: 7
max: 8
passed: true
comment: Title is bold 24pt, axis titles 20pt, tick labels 16pt, legend text
14-18pt - all perfectly readable
comment: Font sizes explicitly set (title=24, axis=20, ticks=16); legend_text=14pt
below 16pt minimum
- id: VQ-02
name: No Overlap
score: 8
max: 8
score: 5
max: 6
passed: true
comment: No overlapping text, all region labels clearly separated, value labels
well-positioned
comment: Good overall; Latin America column has tight segments but threshold
logic avoids crowding
- id: VQ-03
name: Element Visibility
score: 8
max: 8
score: 6
max: 6
passed: true
comment: Rectangles clearly visible with white borders, appropriate sizing
comment: All segments clearly visible; white separator lines provide good
definition
- id: VQ-04
name: Color Accessibility
score: 4
max: 5
score: 1
max: 2
passed: true
comment: Good color contrast, distinct hues; blue/teal could be slightly more
distinct for some colorblind viewers
comment: Colors are distinct but custom palette is not CVD-safe; teal/blue
confusion risk
- id: VQ-05
name: Layout Balance
name: Layout & Canvas
score: 4
max: 5
max: 4
passed: true
comment: Good use of canvas, slight imbalance with legend taking space
comment: Good 16:9 utilization; chart fills canvas with balanced margins
- id: VQ-06
name: Axis Labels
name: Axis Labels & Title
score: 2
max: 2
passed: true
comment: 'Descriptive labels: "Market Segment (width = total market size)"
and "Product Share (%)"'
comment: Descriptive axis labels with context
- id: VQ-07
name: Grid & Legend
name: Palette Compliance
score: 0
max: 2
passed: false
comment: 'FAIL: #306998 (Python Blue) explicitly listed as non-compliant.
All product colors are arbitrary custom hexes, not Okabe-Ito. Code lacks
ANYPLOT_THEME handling; background not #FAF8F1/#1A1A17 via code.'
design_excellence:
score: 10
max: 20
items:
- id: DE-01
name: Aesthetic Sophistication
score: 4
max: 8
passed: true
comment: Well-configured library default; custom Python palette is creative
but violates style guide
- id: DE-02
name: Visual Refinement
score: 3
max: 6
passed: true
comment: theme_minimal() removes spines, white border lines on segments add
polish. Above defaults.
- id: DE-03
name: Data Storytelling
score: 3
max: 6
passed: true
comment: Horizontal grid lines present but vertical grid appropriately hidden;
however y-axis grid could be more subtle
comment: Subtitle visible in images adds story; variable widths naturally
tell the market-size story. Subtitle absent from current code.
spec_compliance:
score: 25
max: 25
score: 14
max: 15
items:
- id: SC-01
name: Plot Type
score: 8
max: 8
passed: true
comment: Correct Marimekko/mosaic chart with variable-width bars
- id: SC-02
name: Data Mapping
score: 5
max: 5
passed: true
comment: X-category (regions) determines width, Y-category (products) for
stacking
- id: SC-03
comment: 'Correct Marimekko: variable-width bars proportional to column totals,
stacked proportions'
- id: SC-02
name: Required Features
score: 5
max: 5
score: 4
max: 4
passed: true
comment: Variable widths, stacking, color coding, value labels on larger segments,
legend present
- id: SC-04
name: Data Range
comment: Proportional widths, stacked proportions, color legend, value labels
on larger segments, centered x-axis labels
- id: SC-03
name: Data Mapping
score: 3
max: 3
passed: true
comment: All data visible, 0-100% y-axis, full x-axis coverage
- id: SC-05
name: Legend Accuracy
score: 2
max: 2
passed: true
comment: Legend correctly identifies all four product lines
- id: SC-06
name: Title Format
comment: Regions on x-axis with proportional widths; product share % on y-axis
- id: SC-04
name: Title & Legend
score: 2
max: 2
max: 3
passed: true
comment: '"Market Share by Region · marimekko-basic · plotnine · pyplots.ai"'
comment: Code title has 'pyplots.ai' instead of 'anyplot.ai'; legend labels
correct
data_quality:
score: 19
max: 20
score: 14
max: 15
items:
- id: DQ-01
name: Feature Coverage
score: 7
max: 8
score: 5
max: 6
passed: true
comment: Shows varying bar widths (Latin America smallest), different product
mixes per region; could show more extreme variation
comment: Shows both Marimekko dimensions (variable width + stacked proportion)
with good variation across 4 regions and 4 products
- id: DQ-02
name: Realistic Context
score: 7
max: 7
score: 5
max: 5
passed: true
comment: 'Real business scenario: market share by region and product line
with plausible data'
comment: Market share data with real business context; neutral topic; plausible
values
- id: DQ-03
name: Appropriate Scale
score: 5
max: 5
score: 4
max: 4
passed: true
comment: Values in $M range appropriate for market data, percentages 0-100%
comment: Values $30M-$200M per segment, $150M-$450M totals per region — realistic
market sizes
code_quality:
score: 9
max: 10
Expand All @@ -168,41 +190,62 @@ review:
score: 3
max: 3
passed: true
comment: 'Linear flow: imports → data → calculations → plot → save (no functions/classes)'
comment: 'Flat procedural: data → compute widths → compute y-positions → plot
→ save'
- id: CQ-02
name: Reproducibility
score: 2
max: 3
max: 2
passed: true
comment: Data is deterministic but no explicit seed; data values are hardcoded
so reproducible
comment: Static hardcoded data; fully deterministic
- id: CQ-03
name: Clean Imports
score: 2
max: 2
passed: true
comment: All imports are used
comment: All imported symbols are used
- id: CQ-04
name: No Deprecated API
score: 1
max: 1
name: Code Elegance
score: 2
max: 2
passed: true
comment: Uses current plotnine API
comment: Clean implementation; loop for cumulative y-positions is appropriate
for Marimekko
- id: CQ-05
name: Output Correct
score: 1
name: Output & API
score: 0
max: 1
passed: true
comment: Saves as plot.png
library_features:
score: 3
max: 5
passed: false
comment: 'FAIL: Saves to ''plot.png'' instead of ''plot-{THEME}.png''; no
ANYPLOT_THEME env-var read; no theme-adaptive chrome'
library_mastery:
score: 6
max: 10
items:
- id: LF-01
name: Uses distinctive library features
score: 3
- id: LM-01
name: Idiomatic Usage
score: 4
max: 5
passed: true
comment: Uses ggplot grammar (geom_rect, geom_text, scale_*, theme), but geom_rect
is basic; could have used coord_fixed or more advanced grammar features
comment: 'Good grammar of graphics usage: ggplot + geom_rect + scale_fill_manual
+ theme. Missing theme-adaptive element_rect/element_text tokens.'
- id: LM-02
name: Distinctive Features
score: 2
max: 5
passed: true
comment: geom_rect() with aes(xmin/xmax/ymin/ymax) for Marimekko construction
is the plotnine-idiomatic approach
verdict: APPROVED
impl_tags:
dependencies: []
techniques:
- manual-ticks
- annotations
patterns:
- iteration-over-groups
dataprep:
- groupby-aggregation
- cumulative-sum
styling:
- edge-highlighting
Loading