Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: zero width lines need no pattern#29302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
rcomer wants to merge1 commit intomatplotlib:mainfromrcomer:coll-ls-scale0
Closed
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionlib/matplotlib/lines.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -77,7 +77,7 @@ def _scale_dashes(offset, dashes, lw):
return offset, dashes
scaled_offset = offset * lw
scaled_dashes = ([x * lw if x is not None else None for x in dashes]
if dashes is not None else None)
if dashes is not Noneand lw > 0else None)
return scaled_offset, scaled_dashes


Expand Down
10 changes: 10 additions & 0 deletionslib/matplotlib/tests/test_collections.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -680,6 +680,16 @@ def test_set_wrong_linestyle():
c.set_linestyle('fuzzy')


@mpl.style.context('default')
def test_zero_linewidth_scaling():
c = Collection()
c.set_linestyle('dashed')
c.set_linewidth(0)

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

@timhoffmtimhoffmDec 13, 2024
edited
Loading

Choose a reason for hiding this comment

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

Note that "solid" results in[('', None)] instead which I believe is incorrect wrt. to the declared type.

We are overall not consistent and clear whatget_linestyle() means:

  • forLine2D.get_linestyle() it is always a str, and if given a dash pattern, the result is "--".
  • forPatch.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 whatget_linestyle() means - and a scaled dash pattern would be the last of my choices.

rcomer reacted with thumbs up emoji
Copy link
MemberAuthor

@rcomerrcomerDec 13, 2024
edited
Loading

Choose a reason for hiding this comment

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

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.



@mpl.style.context('default')
def test_capstyle():
col = mcollections.PathCollection([])
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp