FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: zero width lines need no pattern by rcomer · Pull Request #29302 · matplotlib/matplotlib · GitHub

Repository navigation

FIX: zero width lines need no pattern - #29302

Closed
rcomer wants to merge 1 commit into
matplotlib:mainfrom
rcomer:coll-ls-scale0
Closed

rcomer wants to merge 1 commit into
matplotlib:mainfrom
rcomer:coll-ls-scale0

Conversation

rcomer commented Dec 13, 2024

Copy link
Copy Markdown
Member

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

c.set_linewidth(0)

# With a zero linewidth, there can be no pattern
assert c.get_linestyle() == [(0, None)]

timhoffm Dec 13, 2024 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

rcomer Dec 13, 2024 •
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: set linestyle='dashed' raise error with quiver and legend

2 participants


Back | FazBrowse Home | New Git URL