Skip to content

Fix Collection.draw() single-path optimization when edgecolor/facecolor is 'none' - #32232

Draft
ayshih wants to merge 1 commit into
matplotlib:mainfrom
ayshih:path_optimization_color_none
Draft

Fix Collection.draw() single-path optimization when edgecolor/facecolor is 'none'#32232
ayshih wants to merge 1 commit into
matplotlib:mainfrom
ayshih:path_optimization_color_none

Conversation

@ayshih

@ayshih ayshih commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

PR summary

Fixes #17790. The immediate bug is that setting facecolor or edgecolor to "none" sets the color to an empty list, but the Collection.draw() logic to detect for single-path optimization does not consider an empty list to be a single color. That is, single-path optimization would never happen if facecolor or edgecolor is set to "none". This PR fixes that situation.

That said, this PR requires discussion because single-path optimization is newly triggered in 30+ figure tests, which means their baseline images need to be updated. This is because draw_markers() produces different output than draw_path_collection(). It's worth investigating whether single-path optimization is in fact appropriate in all cases before accepting this PR.

AI Disclosure

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • [N/A] Plotting related features are demonstrated in an example
  • [N/A] New features and API changes have release notes
  • [N/A] Documentation complies with general and docstring guidelines

@ayshih
ayshih force-pushed the path_optimization_color_none branch from 571623a to 1d57e2b Compare August 19, 2026 15:44
@ayshih

ayshih commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

That said, this PR requires discussion because single-path optimization is newly triggered in 30+ figure tests, which means their baseline images need to be updated. This is because draw_markers() produces different output than draw_path_collection(). It's worth investigating whether single-path optimization is in fact appropriate in all cases before accepting this PR.

  • We could reduce the number of images affected by this PR by creating a way to disable single-path optimization where it is not appropriate given the collection type.
  • We could review the (Agg) code for draw_markers() and draw_path_collection() to see if there are any bugs that are contributing to the discrepancies between the rendered output.

@QuLogic

QuLogic commented Aug 20, 2026

Copy link
Copy Markdown
Member

There's been a long standing bug with the single-path optimization #15946 Possibly #32108 may be relevant here, though I didn't test that specific case yet.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using facecolors='none' with a scatter plot results in off-centered symbols

2 participants