diff --git a/plots/pie-basic/implementations/pygal.py b/plots/pie-basic/implementations/pygal.py index 66a439d821..57d40d0239 100644 --- a/plots/pie-basic/implementations/pygal.py +++ b/plots/pie-basic/implementations/pygal.py @@ -1,51 +1,71 @@ """ pyplots.ai pie-basic: Basic Pie Chart -Library: pygal 3.1.0 | Python 3.13.11 -Quality: 91/100 | Created: 2025-12-23 +Library: pygal 3.1.0 | Python 3.14.0 +Quality: 90/100 | Created: 2025-12-23 """ import pygal from pygal.style import Style -# Data - Market share distribution -categories = ["Product A", "Product B", "Product C", "Product D", "Product E"] -values = [35, 25, 20, 12, 8] +# Data - Global smartphone market share (2024) +categories = [("Apple", 23.3), ("Samsung", 19.4), ("Xiaomi", 14.1), ("OPPO", 8.7), ("vivo", 7.5), ("Others", 27.0)] + +# Saturated, high-contrast palette — colorblind-safe (no red-green ambiguity) +palette = ("#2563EB", "#D97706", "#0D9488", "#E11D48", "#7C3AED", "#64748B") -# Custom style for 3600x3600 px (square format for pie chart) custom_style = Style( background="white", plot_background="white", - foreground="#333", - foreground_strong="#333", - foreground_subtle="#666", - colors=("#306998", "#FFD43B", "#4ECDC4", "#FF6B6B", "#95E1D3"), - title_font_size=72, + foreground="#1E293B", + foreground_strong="#0F172A", + foreground_subtle="#94A3B8", + colors=palette, + title_font_size=76, label_font_size=48, major_label_font_size=48, - legend_font_size=42, - value_font_size=42, + value_label_font_size=44, + legend_font_size=60, + value_font_size=56, tooltip_font_size=36, + value_colors=("#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF", "#FFFFFF"), + stroke_opacity=1, ) -# Create pie chart chart = pygal.Pie( width=3600, height=3600, style=custom_style, - title="pie-basic · pygal · pyplots.ai", + title="Smartphone Market Share · pie-basic · pygal · pyplots.ai", inner_radius=0, legend_at_bottom=True, - legend_at_bottom_columns=5, + legend_at_bottom_columns=3, + legend_box_size=40, print_values=True, + print_labels=True, print_values_position="center", - value_formatter=lambda x: f"{x}%", + value_formatter=lambda x: f"{x:.1f}%", + margin=60, + margin_bottom=100, + truncate_legend=-1, ) -# Add data slices -for category, value in zip(categories, values, strict=True): - chart.add(category, value) +# Storytelling: narrative legend names convey insight; on-slice labels add context +legend_names = {"Others": "Others (largest segment)", "Apple": "Apple (#1 brand)", "Samsung": "Samsung (#2 worldwide)"} + +for company, value in categories: + slice_css = "stroke: white; stroke-width: 5" + slice_data = {"value": value, "style": slice_css} + + # Explode the largest slice ("Others") with a subtle fixed offset for emphasis + if company == "Others": + slice_data["node"] = {"transform": "translate(0, -18)"} + slice_data["label"] = "Largest" + elif company == "Apple": + slice_data["label"] = "#1 brand" + + name = legend_names.get(company, company) + chart.add(name, [slice_data]) -# Save as PNG and HTML chart.render_to_png("plot.png") chart.render_to_file("plot.html") diff --git a/plots/pie-basic/metadata/pygal.yaml b/plots/pie-basic/metadata/pygal.yaml index 55a07e72b8..88a27f8916 100644 --- a/plots/pie-basic/metadata/pygal.yaml +++ b/plots/pie-basic/metadata/pygal.yaml @@ -1,16 +1,16 @@ library: pygal specification_id: pie-basic created: '2025-12-23T00:35:27Z' -updated: '2025-12-23T00:38:26Z' -generated_by: claude-opus-4-5-20251101 +updated: '2026-02-14T15:08:44Z' +generated_by: claude-opus-4-6 workflow_run: 20447776548 issue: 0 -python_version: 3.13.11 +python_version: 3.14.0 library_version: 3.1.0 preview_url: https://storage.googleapis.com/pyplots-images/plots/pie-basic/pygal/plot.png preview_thumb: https://storage.googleapis.com/pyplots-images/plots/pie-basic/pygal/plot_thumb.png preview_html: https://storage.googleapis.com/pyplots-images/plots/pie-basic/pygal/plot.html -quality_score: 91 +quality_score: 90 impl_tags: dependencies: [] techniques: @@ -18,139 +18,159 @@ impl_tags: patterns: - iteration-over-groups dataprep: [] - styling: [] + styling: + - edge-highlighting review: strengths: - - Clean, readable code following KISS principles with clear section comments - - Excellent color palette with good contrast and colorblind accessibility - - Proper use of pygal Style class for comprehensive customization - - Percentage labels are well-positioned and clearly readable inside slices - - Correct title format following pyplots.ai conventions - - Generates both PNG and HTML outputs for flexibility + - Excellent data storytelling through enriched legend names and on-slice contextual + labels that guide the viewer + - Strong colorblind-safe palette with good visual separation via white stroke between + slices + - Creative use of pygal SVG node transform for slice explosion effect — distinctly + pygal approach + - Clean flat code structure with deterministic data and no unnecessary dependencies + - Perfect spec compliance with all four required features implemented weaknesses: - - Legend at bottom appears relatively small compared to the pie chart; could increase - legend_font_size for better readability - - Missing slight explosion for emphasis on key slice as suggested in the specification - notes - image_description: 'The plot displays a pie chart showing market share distribution - across 5 products. The chart uses a square format (3600x3600px) with distinct - colors: blue (#306998) for Product A (35%), yellow (#FFD43B) for Product B (25%), - teal (#4ECDC4) for Product C (20%), coral/red (#FF6B6B) for Product D (12%), and - mint green (#95E1D3) for Product E (8%). Each slice displays its percentage value - centered within the slice. The title "pie-basic · pygal · pyplots.ai" appears - at the top in dark gray text. A horizontal legend at the bottom identifies all - 5 products with their corresponding color indicators arranged in 5 columns.' + - Minor label crowding in the OPPO and vivo small slices — tight but still readable + - Slight excess whitespace above the title area + - Monospace font rendering from pygal SVG-to-PNG pipeline is functional but not + as polished as proportional fonts + image_description: 'The plot shows a pie chart on a white 3600x3600 background titled + "Smartphone Market Share · pie-basic · pygal · pyplots.ai" at the top in dark + text. Six slices represent global smartphone market share: Apple (blue, 23.3%), + Samsung (orange, 19.4%), Xiaomi (teal, 14.1%), OPPO (rose/pink, 8.7%), vivo (purple, + 7.5%), and Others (gray, 27.0%). Each slice displays a white percentage label. + The "Others" slice is slightly exploded outward for emphasis. Apple''s slice carries + an additional "#1 brand" label and the Others slice shows "Largest." White strokes + separate all slices. A bottom legend in two rows of three uses enriched names: + "Apple (#1 brand)", "Samsung (#2 worldwide)", "Xiaomi", "OPPO", "vivo", "Others + (largest segment)." Colors are distinct and colorblind-safe (blue, amber, teal, + rose, purple, gray).' criteria_checklist: visual_quality: - score: 36 - max: 40 + score: 27 + max: 30 items: - id: VQ-01 name: Text Legibility - score: 10 - max: 10 + score: 7 + max: 8 passed: true - comment: Title and percentage labels are clearly readable at the large canvas - size + comment: All font sizes explicitly set (title 76, labels 48, legend 60, values + 56). Readable throughout, minor cramping in small slices. - id: VQ-02 name: No Overlap - score: 8 - max: 8 + score: 5 + max: 6 passed: true - comment: No overlapping text elements; percentages are well-positioned within - slices + comment: No actual text overlap. Percentage labels for OPPO and vivo in tight + slices but remain readable. - id: VQ-03 name: Element Visibility - score: 8 - max: 8 + score: 6 + max: 6 passed: true - comment: Pie slices are well-proportioned and clearly visible + comment: All slices clearly visible, white stroke provides excellent slice + delineation. - id: VQ-04 name: Color Accessibility - score: 5 - max: 5 + score: 4 + max: 4 passed: true - comment: Colors are distinct and colorblind-friendly (no red-green as only - difference) + comment: Colorblind-safe palette avoiding red-green ambiguity. - id: VQ-05 name: Layout Balance score: 3 - max: 5 + max: 4 passed: true - comment: Good overall layout, but legend at bottom appears small relative - to chart - - id: VQ-07 - name: Grid & Legend - score: 0 + comment: Pie fills canvas well, legend at bottom in 3 columns. Slight excess + whitespace at top. + - id: VQ-06 + name: Axis Labels & Title + score: 2 max: 2 - passed: false - comment: Legend text appears quite small compared to the chart; could be more - prominent + passed: true + comment: Descriptive title with context. No axes needed for pie chart. + design_excellence: + score: 15 + max: 20 + items: + - id: DE-01 + name: Aesthetic Sophistication + score: 6 + max: 8 + passed: true + comment: Custom palette, white stroke separation, intentional typography hierarchy, + enriched legend names. Above default but not FiveThirtyEight-level. + - id: DE-02 + name: Visual Refinement + score: 4 + max: 6 + passed: true + comment: Clean white background, no unnecessary chrome, custom margins, well-organized + bottom legend. + - id: DE-03 + name: Data Storytelling + score: 5 + max: 6 + passed: true + comment: Enriched legend names convey narrative, on-slice labels, exploded + largest slice draws attention. spec_compliance: - score: 25 - max: 25 + score: 15 + max: 15 items: - id: SC-01 name: Plot Type - score: 8 - max: 8 - passed: true - comment: Correct pie chart type - - id: SC-02 - name: Data Mapping score: 5 max: 5 passed: true - comment: Categories and values correctly mapped to slices - - id: SC-03 + comment: Correct pie chart type. + - id: SC-02 name: Required Features - score: 5 - max: 5 + score: 4 + max: 4 passed: true - comment: Includes percentage labels, distinct colors, and legend as specified - - id: SC-04 - name: Data Range + comment: Percentage labels, distinct colors, legend, exploded slice — all + present. + - id: SC-03 + name: Data Mapping score: 3 max: 3 passed: true - comment: All data visible, percentages sum to 100% - - id: SC-05 - name: Legend Accuracy - score: 2 - max: 2 - passed: true - comment: Legend correctly identifies all categories - - id: SC-06 - name: Title Format - score: 2 - max: 2 + comment: Categories mapped to slices, values to proportional angles. + - id: SC-04 + name: Title & Legend + score: 3 + max: 3 passed: true - comment: 'Uses correct format: "pie-basic · pygal · pyplots.ai"' + comment: Title follows required format. Legend labels correctly identify all + categories. data_quality: - score: 18 - max: 20 + score: 14 + max: 15 items: - id: DQ-01 name: Feature Coverage - score: 6 - max: 8 + score: 5 + max: 6 passed: true - comment: Shows different sized slices demonstrating proportions, but missing - "explosion" feature mentioned in spec notes + comment: Good variation in slice sizes (7.5% to 27%), includes Others aggregation. - id: DQ-02 name: Realistic Context - score: 7 - max: 7 + score: 5 + max: 5 passed: true - comment: Market share distribution is a realistic, comprehensible scenario + comment: Global smartphone market share 2024 with recognizable companies. + Neutral business scenario. - id: DQ-03 name: Appropriate Scale - score: 5 - max: 5 + score: 4 + max: 4 passed: true - comment: Values (35%, 25%, 20%, 12%, 8%) are realistic for market share + comment: Values sum to 100%, realistic market share percentages. code_quality: - score: 9 + score: 10 max: 10 items: - id: CQ-01 @@ -158,40 +178,48 @@ review: score: 3 max: 3 passed: true - comment: Simple imports → data → plot → save structure, no functions/classes + comment: 'Flat script: imports, data, style, chart config, loop, render.' - id: CQ-02 name: Reproducibility - score: 3 - max: 3 + score: 2 + max: 2 passed: true - comment: Deterministic data (no random elements) + comment: Deterministic hardcoded data, no randomness. - id: CQ-03 name: Clean Imports score: 2 max: 2 passed: true - comment: Only pygal and Style imported, both used + comment: Only pygal and pygal.style.Style imported, both used. - id: CQ-04 - name: No Deprecated API + name: Code Elegance + score: 2 + max: 2 + passed: true + comment: Clean loop with dict-based slice config. Creative SVG node transform + for explode. + - id: CQ-05 + name: Output & API score: 1 max: 1 passed: true - comment: Uses current pygal API - - id: CQ-05 - name: Output Correct - score: 0 - max: 0 - passed: false - comment: Saves as plot.png correctly - library_features: - score: 3 - max: 5 + comment: Saves as plot.png and plot.html. + library_mastery: + score: 9 + max: 10 items: - - id: LF-01 - name: Uses distinctive library features - score: 3 + - id: LM-01 + name: Idiomatic Usage + score: 5 + max: 5 + passed: true + comment: Uses pygal Pie class, Style, print_values, value_formatter, legend_at_bottom_columns, + render_to_png. + - id: LM-02 + name: Distinctive Features + score: 4 max: 5 passed: true - comment: Uses pygal's Style customization and render_to_png/render_to_file, - but doesn't use unique features like hover interactivity or half-pie mode + comment: SVG node manipulation for exploding slices, value_formatter lambda, + value_colors, truncate_legend, dual output. verdict: APPROVED