Skip to content

Enable path simplification for FillBetweenPolyCollection to reduce vector output size#31361

Open
saitejaponnam12 wants to merge 2 commits intomatplotlib:mainfrom
saitejaponnam12:fix-fill-between-simplify
Open

Enable path simplification for FillBetweenPolyCollection to reduce vector output size#31361
saitejaponnam12 wants to merge 2 commits intomatplotlib:mainfrom
saitejaponnam12:fix-fill-between-simplify

Conversation

@saitejaponnam12
Copy link

@saitejaponnam12 saitejaponnam12 commented Mar 24, 2026

PR summary

This patch enables path simplification for FillBetweenPolyCollection.

Currently, Axes.fill_between generates dense closed polygons (≈2N vertices), which leads to very large SVG/PDF outputs.
Although Matplotlib has path simplification support, collection templates in vector backends bypass it.

This change marks paths created by FillBetweenPolyCollection with should_simplify=True, allowing existing simplification logic to reduce redundant vertices when saving vector graphics.

Why is this change necessary?

Vector outputs created using fill_between can become excessively large due to dense polygon paths. This makes files slow to render and inefficient to store.

What problem does it solve?

Enables simplification of fill_between polygons, significantly reducing SVG/PDF file sizes.

Implementation reasoning

  • Uses existing Path.should_simplify mechanism
  • Targets only FillBetweenPolyCollection
  • No API changes
  • Minimal and safe modification

This is a focused change that leverages existing infrastructure without altering default behavior for other collections.

AI Disclosure

I used AI assistance for understanding the codebase structure and drafting the initial implementation idea. The final code change and testing decisions were reviewed and validated manually.

PR checklist

  • "closes #0000" is in the body of the PR description to link the related issue (N/A)
  • new and changed code is tested (manual validation of behavior)
  • Plotting related features demonstrated in example (N/A)
  • New Features and API Changes noted (N/A)
  • Documentation complies with guidelines (N/A)

Copilot AI review requested due to automatic review settings March 24, 2026 05:17
@github-actions
Copy link

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on gitter for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

@saitejaponnam12
Copy link
Author

Thanks for reviewing! Please let me know if any additional tests, benchmarks, or documentation updates would be helpful. I'm happy to iterate on this PR.

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants