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

Various issues with miter limits #9830

Open
Labels
keepItems to be ignored by the “Stale” Github Action
@anntzer

Description

@anntzer

Noticed this a while ago (while implementing mplcairo) but prompted to report due to#9829:

from matplotlib import pyplot as plt, tickerfig, axs = plt.subplots(4, 4)for i, ax in enumerate(axs.flat):    ax.xaxis.set_major_locator(ticker.NullLocator())    ax.yaxis.set_major_locator(ticker.NullLocator())    ax.plot([-1, 0, 1], [0, 1, 0], lw=i, solid_joinstyle="miter")    ax.set(xlim=(-15, 15), ylim=(0, 3))fig.savefig("/tmp/test.png")fig.savefig("/tmp/test.svg")fig.savefig("/tmp/test.pdf")plt.show()

pdf appears to respect the miter ("pointed") joinstyle (funnily this appears to behave in the opposite manner as#9829):
test-pdf
svg appears to ignore it:
test-svg
agg changes its mind half-way:
test

The behavior of agg is almost certainly due to a misunderstanding in how the miter limit is set. Seehttps://www.w3schools.com/tags/canvas_miterlimit.asp andhttps://www.cairographics.org/manual/cairo-cairo-t.html#cairo-set-miter-limit for the definition of the miter limit. Note that the two definitions differ: html defines it in absolute lengths whereas cairo defines it relative to the linewidth.

backend_agg.h has the line (multiple times)

stroke.miter_limit(points_to_pixels(gc.linewidth));

which suggest that the author thought miter_limit takes an absolute miter limit, but in fact a relative miter limit should have been given (how do I know this? because I can reproduce the same behavior with mplcairo with the same setting, and cairo clearly documents that it uses a relative miter limit :-)).

So the current implementation ends up switching from miter join to bevel join at an angle that depends on the linewidth, eek.


NOTE: when this is fixed, remember to regen the logo per#14939 (which also showcases the issue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    keepItems to be ignored by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp