Enable path simplification for FillBetweenPolyCollection to reduce vector output size#31361
Enable path simplification for FillBetweenPolyCollection to reduce vector output size#31361saitejaponnam12 wants to merge 2 commits intomatplotlib:mainfrom
Conversation
|
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. We strive to be a welcoming and open project. Please follow our Code of Conduct. |
|
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. |
PR summary
This patch enables path simplification for
FillBetweenPolyCollection.Currently,
Axes.fill_betweengenerates 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
FillBetweenPolyCollectionwithshould_simplify=True, allowing existing simplification logic to reduce redundant vertices when saving vector graphics.Why is this change necessary?
Vector outputs created using
fill_betweencan 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_betweenpolygons, significantly reducing SVG/PDF file sizes.Implementation reasoning
Path.should_simplifymechanismFillBetweenPolyCollectionThis 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