Repository navigation
FIX: do not simplify path in LineCollection.get_segments - #20584
Merged
anntzer merged 1 commit intoJul 6, 2021
Merged
Conversation
Internally all Collection flavors boil down to calling renderer.draw_path_collection and the sub-classes primarily provide nicer user-facing APIs to fabricate the paths that will be passed down to the renderer. In LineCollection rather than tracking both the user supplied data and the internal Path objects, we just keep the Path objects and re-extract segments on demand. To do this we use Path.iter_segments with defaults to asking the path if it should simplify the path (that is drop points that do not matter which is in turn defined by if the deflection away from "straight" is greater than some threshold). The Path objects we are holding have values in data-space, but the default value of "what is the threshold for 'not mattering'" is tuned to make sense in to pixel space (1/9). By passing `simplify=False` to `iter_segments` we over-ride the Path object's notion of if it should be simplified (which by default is controlled by the simplify threshold (rcParams['path.simplify_threshold']), rcParams['path.simplify'] , how long the path is, and if there are any quadratic or Bézier codes in the path) to never simplify. In this application we never want to simplify because we do not know enough of the context when this is called to know what the "right" simplification threshold is and because we expect `set_segments` and `get_segments` to round-trip. closes matplotlib#20551
timhoffm
approved these changes
Jul 6, 2021
anntzer
approved these changes
Jul 6, 2021
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
tacaswell
pushed a commit
to tacaswell/matplotlib
that referenced
this pull request
Jul 6, 2021
…_simplified_segments
FIX: do not simplify path in LineCollection.get_segments
Conflicts:
lib/matplotlib/tests/test_collections.py
- only backport the new test
tacaswell
pushed a commit
to tacaswell/matplotlib
that referenced
this pull request
Jul 6, 2021
…tion.get_segments Merge pull request matplotlib#20584 from tacaswell/fix_linecollection_simplified_segments FIX: do not simplify path in LineCollection.get_segments Conflicts: lib/matplotlib/tests/test_collections.py - only backport the new test
7 tasks
jklymak
added a commit
that referenced
this pull request
Jul 6, 2021
…-v3.4.x Backport PR #20584: FIX: do not simplify path in LineCollection.get_s…
davidgegiya
added a commit
to davidgegiya/agent-orchestrator
that referenced
this pull request
Nov 8, 2026
Pin 06141dab06373d0cb2806b3aa87ca621fbf5c426 and its regression selectors for reproducible runs. Source: matplotlib/matplotlib#20584
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Internally all Collection flavors boil down to calling
renderer.draw_path_collection and the sub-classes primarily provide nicer
user-facing APIs to fabricate the paths that will be passed down to the
renderer.
In LineCollection rather than tracking both the user supplied data and the
internal Path objects, we just keep the Path objects and re-extract segments on
demand.
To do this we use Path.iter_segments with defaults to asking the path if it
should simplify the path (that is drop points that do not matter which is in
turn defined by if the deflection away from "straight" is greater than some
threshold). The Path objects we are holding have values in data-space, but the
default value of "what is the threshold for 'not mattering'" is tuned to make
sense in to pixel space (1/9). By passing
simplify=Falsetoiter_segmentswe over-ride the Path object's notion of if it should be simplified (which by
default is controlled by the simplify
threshold (rcParams['path.simplify_threshold']), rcParams['path.simplify'] ,
how long the path is, and if there are any quadratic or Bézier codes in the
path) to never simplify.
In this application we never want to simplify because we do not know enough of
the context when this is called to know what the "right" simplification
threshold is and because we expect
set_segmentsandget_segmentstoround-trip.
closes #20551
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).