FIX: zero width lines need no pattern#29302
Closed
rcomer wants to merge 1 commit intomatplotlib:mainfrom
Closed
Conversation
timhoffm
reviewed
Dec 13, 2024
| c.set_linewidth(0) | ||
|
|
||
| # With a zero linewidth, there can be no pattern | ||
| assert c.get_linestyle() == [(0, None)] |
Member
There was a problem hiding this comment.
Note that "solid" results in [('', None)] instead which I believe is incorrect wrt. to the declared type.
We are overall not consistent and clear what get_linestyle() means:
- for
Line2D.get_linestyle()it is always a str, and if given a dash pattern, the result is "--". - for
Patch.get_linestyle(), we basically get what we put in str or (unscaled) dash pattern; with the exception of normalizing "no style" ' ', '', 'none' to "None" - for Collections, we always get a scaled dash pattern.
While this fix may be ok as a workaround to fix the original issue (and doesn't make the consisteny worse), we should generally agee upon what get_linestyle() means - and a scaled dash pattern would be the last of my choices.
Member
Author
There was a problem hiding this comment.
Actually looking closer, I don't think the legend handler should be getting the scaled pattern - it gets scaled again on the patch, so is wrong for any linewidth != 1.
I'll close this.
This was referenced Dec 13, 2024
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
Proposal to fix #28298. If the linewidth is zero then the dash pattern is arbitrary, so set the scaled pattern to
None, which is the same as solid lines.PR checklist