Skip to content

feat: add pie-basic implementation (9 libraries)#513

Merged
MarkusNeusinger merged 10 commits intomainfrom
plot/pie-basic
Dec 7, 2025
Merged

feat: add pie-basic implementation (9 libraries)#513
MarkusNeusinger merged 10 commits intomainfrom
plot/pie-basic

Conversation

@MarkusNeusinger
Copy link
Copy Markdown
Owner

Summary

Adds pie-basic plot implementation.

Libraries

  • Merged: 9 (all libraries)
  • Not Feasible: 0

Links


🤖 Auto-generated by pyplots CI

claude bot and others added 10 commits December 7, 2025 00:53
## Summary
Implements `pie-basic` for **altair** library.

**Parent Issue:** #206
**Sub-Issue:** #265
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/altair/arc/pie-basic/default.py`

## Changes
- Simplified implementation to follow KISS principle (script style, no
function wrapper)
- Uses PyPlots.ai default color palette for consistent styling
- Includes percentage labels on pie slices
- Adds interactive tooltips showing category, value, and percentage
- Properly configured legend and chart dimensions

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **matplotlib** library.

**Parent Issue:** #206
**Sub-Issue:** #235
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/matplotlib/pie/pie-basic/default.py`

## Changes
- Simplified implementation following KISS principle (no functions, no
classes)
- Uses style guide colors: Python Blue, Python Yellow, Signal Red, Teal
Green, Violet
- Proper figure sizing (16x9 aspect ratio) for 4800x2700px output at 300
DPI
- Clear percentage labels and category labels with appropriate font
sizes
- Slight explode effect for better visual separation

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **seaborn** library.

**Parent Issue:** #206
**Sub-Issue:** #243
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/seaborn/pie/pie-basic/default.py`

## Notes
- Seaborn does not have a native pie chart function
- Uses matplotlib's `ax.pie()` with seaborn's styling context
(`sns.set_theme(style="white")`) for consistent aesthetics
- Follows KISS script style (no functions, no type hints)
- Uses PyPlots.ai color palette
- Configured for 16:9 aspect ratio output at 300 DPI
- Font sizes follow style guide (title: 20pt, legend/labels: 16pt)

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **plotly** library.

**Parent Issue:** #206
**Sub-Issue:** #251
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/plotly/pie/pie-basic/default.py`

## Changes
- Simplified implementation following KISS pattern (no functions,
sequential code)
- Uses PyPlots color palette from style guide
- Proper 16:9 aspect ratio (4800x2700px via scale=3)
- Clean Plotly white template with legend on right side
- Labels with percentages displayed inside pie slices

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **pygal** library.

**Parent Issue:** #206
**Sub-Issue:** #273
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/pygal/pie/pie-basic/default.py`

## Changes
- Simplified implementation following KISS principles
- Removed function wrapper, type hints, and docstrings per
plot-generator.md guidelines
- Direct sequential code matching gallery example style
- Uses PyPlots color palette from style guide
- 4800x2700 px output with recommended font sizes
- Legend at bottom for clear visibility

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **plotnine** library.

**Parent Issue:** #206
**Sub-Issue:** #270
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/plotnine/pie/pie-basic/default.py`

## Details
- Simplified to KISS pattern (no functions, sequential script)
- Uses matplotlib directly since plotnine lacks `coord_polar()` support
- Applies PyPlots.ai color palette
- Uses 16:9 aspect ratio (figsize 16x9 at 300 dpi)
- Legend positioned outside pie for clarity
- Percentage labels displayed on each slice

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **highcharts** library.

**Parent Issue:** #206
**Sub-Issue:** #276
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/highcharts/pie/pie-basic/default.py`

## Changes
- Rewrote implementation to follow KISS principles (simple sequential
script)
- Removed function wrapper and class structure
- Updated to 4800x2700 px dimensions per style guide
- Added proper Selenium element screenshot for exact dimensions
- Uses PyPlots color palette from style guide

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **letsplot** library.

**Parent Issue:** #206
**Sub-Issue:** #279
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/letsplot/pie/pie-basic/default.py`

## Details
- Uses lets-plot's `geom_pie()` with `stat='identity'` for pre-computed
values
- Applies PyPlots.ai color palette via `scale_fill_manual()`
- Output dimensions: 4800×2700px (1600×900 base scaled 3x)
- Includes title, legend with proper theming using `theme_void()` +
custom `theme()`

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
## Summary
Implements `pie-basic` for **bokeh** library.

**Parent Issue:** #206
**Sub-Issue:** #259
**Base Branch:** `plot/pie-basic`
**Attempt:** 1/3

## Implementation
- `plots/bokeh/custom/pie-basic/default.py`

## Changes
- Simplified implementation to follow KISS style (no functions, no type
hints)
- Uses wedge glyphs to create pie chart (Bokeh has no native pie chart
method)
- Output size: 4800 × 2700 px per style guide
- Features:
  - PyPlots color palette
  - Percentage labels on slices (hidden for slices < 5%)
  - Interactive tooltips with category, value, and percentage
  - Legend on right side
  - Centered title

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Markus Neusinger <2921697+MarkusNeusinger@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 7, 2025 21:16
@MarkusNeusinger MarkusNeusinger merged commit e444376 into main Dec 7, 2025
@MarkusNeusinger MarkusNeusinger deleted the plot/pie-basic branch December 7, 2025 21:16
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 7, 2025

⏭️ Plot Tests Skipped

No plot files changed

Compatibility: 3.12 3.13

Note: Only Python 3.13 is required to pass. Python 3.12 is tested for compatibility.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements the pie-basic plot specification across all 9 supported plotting libraries, converting implementations from reusable function-based code to standalone executable scripts. Each implementation creates a basic pie chart visualizing market share distribution data with 5 product categories.

Key Changes

  • Removed create_plot() function pattern in favor of direct executable scripts
  • Eliminated TYPE_CHECKING imports and associated type hints
  • Standardized data inline (Product A through Other with values 35, 25, 20, 15, 5)
  • Applied PyPlots.ai color palette consistently across all implementations

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
plots/seaborn/pie/pie-basic/default.py Matplotlib-based pie with seaborn styling; reduced from 158 to 80 lines
plots/pygal/pie/pie-basic/default.py SVG pie chart implementation; simplified from 145 to 44 lines
plots/plotnine/pie/pie-basic/default.py Matplotlib fallback implementation (plotnine lacks coord_polar); reduced from 166 to 72 lines
plots/plotly/pie/pie-basic/default.py Interactive Plotly pie chart; reduced from 215 to 44 lines
plots/matplotlib/pie/pie-basic/default.py Baseline matplotlib implementation; reduced from 167 to 45 lines
plots/letsplot/pie/pie-basic/default.py New lets-plot implementation using geom_pie; 56 lines
plots/highcharts/pie/pie-basic/default.py Headless Chrome screenshot approach; reduced from 262 to 136 lines
plots/bokeh/custom/pie-basic/default.py Wedge-based manual pie construction; reduced from 198 to 123 lines
plots/altair/arc/pie-basic/default.py Declarative arc mark implementation; reduced from 152 to 60 lines

legend_text=element_text(size=14),
legend_position="right",
)
+ ggsize(1600, 900)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent aspect ratio: The plot uses ggsize(1600, 900) which is 16:9 aspect ratio, then scales by 3x to get 4800x2700. However, pie charts typically benefit from a square or circular aspect ratio to prevent distortion. Unlike other chart types, this 16:9 ratio may cause the pie to appear elliptical unless lets-plot automatically maintains aspect ratio. Consider verifying the output or using a square size like ggsize(1600, 1600) scaled to 4800x4800.

Suggested change
+ ggsize(1600, 900)
+ ggsize(1600, 1600)

Copilot uses AI. Check for mistakes.
colors=colors,
autopct="%1.1f%%",
startangle=90,
explode=[0.02] * len(data),
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explode effect applied to all slices: Line 27 applies a uniform explode of 0.02 to all slices using [0.02] * len(data). This defeats the purpose of the explode feature, which is typically used to emphasize specific slices. Either remove the explode parameter entirely for a basic pie chart, or apply it only to selected slices (e.g., the largest or smallest).

Suggested change
explode=[0.02] * len(data),

Copilot uses AI. Check for mistakes.
sample_data = pd.DataFrame(
{"category": ["Product A", "Product B", "Product C", "Product D", "Other"], "value": [35, 25, 20, 15, 5]}
)
ax.set_title("Basic Pie Chart", fontsize=20, fontweight="bold", pad=20)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title inconsistency across implementations. Most libraries use "Market Share Distribution" (seaborn, letsplot, highcharts, bokeh) while some use "Basic Pie Chart" (matplotlib, plotnine, plotly, altair). For consistency, all implementations should use the same title, preferably one that's more descriptive like "Market Share Distribution" which aligns with the spec's use case examples.

Suggested change
ax.set_title("Basic Pie Chart", fontsize=20, fontweight="bold", pad=20)
ax.set_title("Market Share Distribution", fontsize=20, fontweight="bold", pad=20)

Copilot uses AI. Check for mistakes.
)

# Title
ax.set_title("Basic Pie Chart", fontsize=20, fontweight="semibold", pad=20)
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title inconsistency: Uses "Basic Pie Chart" while other implementations (seaborn, letsplot, highcharts, bokeh) use "Market Share Distribution". All implementations should use the same title for consistency.

Suggested change
ax.set_title("Basic Pie Chart", fontsize=20, fontweight="semibold", pad=20)
ax.set_title("Market Share Distribution", fontsize=20, fontweight="semibold", pad=20)

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +41
start_rad = math.radians(90 - 90) # Adjust for Bokeh coordinate system
data["start_angle"] = data["start_angle"] + start_rad
data["end_angle"] = data["end_angle"] + start_rad
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant calculation: The expression math.radians(90 - 90) evaluates to 0. This can be simplified to start_rad = 0 or removed entirely since adding 0 has no effect.

Suggested change
start_rad = math.radians(90 - 90) # Adjust for Bokeh coordinate system
data["start_angle"] = data["start_angle"] + start_rad
data["end_angle"] = data["end_angle"] + start_rad

Copilot uses AI. Check for mistakes.
plt.savefig("plot.png", dpi=300, bbox_inches="tight", facecolor="white")
print("Plot saved to plot.png")
plt.tight_layout()
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing facecolor parameter: The savefig call doesn't specify facecolor="white" like the seaborn and plotnine implementations do. While matplotlib may default to white, explicitly setting it ensures consistency across all implementations and prevents potential issues with different matplotlib configurations.

Suggested change
plt.savefig("plot.png", dpi=300, bbox_inches="tight")
plt.savefig("plot.png", dpi=300, bbox_inches="tight", facecolor="white")

Copilot uses AI. Check for mistakes.

# Layout
fig.update_layout(
title={"text": "Basic Pie Chart", "font": {"size": 20}, "x": 0.5, "xanchor": "center"},
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title inconsistency: Uses "Basic Pie Chart" while other implementations (seaborn, letsplot, highcharts, bokeh) use "Market Share Distribution". All implementations should use the same title for consistency.

Suggested change
title={"text": "Basic Pie Chart", "font": {"size": 20}, "x": 0.5, "xanchor": "center"},
title={"text": "Market Share Distribution", "font": {"size": 20}, "x": 0.5, "xanchor": "center"},

Copilot uses AI. Check for mistakes.
chart = alt.layer(pie, text).properties(
width=800,
height=800,
title=alt.TitleParams(text="Market Share Distribution", fontSize=20, anchor="middle", fontWeight="bold"),
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Title inconsistency: Uses "Market Share Distribution" in the chart title while other implementations use "Basic Pie Chart". All implementations should use the same title for consistency. Note: The comment says "Basic Pie Chart" at line 50 but this is actually just part of the title configuration.

Suggested change
title=alt.TitleParams(text="Market Share Distribution", fontSize=20, anchor="middle", fontWeight="bold"),
title=alt.TitleParams(text="Basic Pie Chart", fontSize=20, anchor="middle", fontWeight="bold"),

Copilot uses AI. Check for mistakes.
chrome_options.add_argument("--window-size=5000,3000")

driver = webdriver.Chrome(options=chrome_options)
driver.get(f"file://{temp_path}")
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File URL format issue: The file URL is missing double slashes. In line 127, it should be f"file:///{temp_path}" (with three slashes for absolute paths on Unix-like systems) rather than f"file://{temp_path}". This could cause issues when loading the HTML file in headless Chrome on some systems.

Suggested change
driver.get(f"file://{temp_path}")
driver.get(Path(temp_path).as_uri())

Copilot uses AI. Check for mistakes.
foreground="#333333",
foreground_strong="#333333",
foreground_subtle="#666666",
colors=("#306998", "#FFD43B", "#DC2626", "#059669", "#8B5CF6"),
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incomplete color palette: The colors tuple in the custom style only includes 5 colors while the data has 5 categories. If this pattern is reused for plots with more categories, the 6th color (Orange, "#F97316") from the PyPlots palette would be missing. Consider including all 6 standard colors for consistency with other implementations.

Suggested change
colors=("#306998", "#FFD43B", "#DC2626", "#059669", "#8B5CF6"),
colors=("#306998", "#FFD43B", "#DC2626", "#059669", "#8B5CF6", "#F97316"),

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants