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

Various issues with miter limits · Issue #9830 · matplotlib/matplotlib · GitHub

Repository navigation

Various issues with miter limits #9830

Open

Description

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

from matplotlib import pyplot as plt, ticker

fig, 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):

svg appears to ignore it:

agg changes its mind half-way:

The behavior of agg is almost certainly due to a misunderstanding in how the miter limit is set. See https://www.w3schools.com/tags/canvas_miterlimit.asp and https://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).

Activity

  1. brunobeltran commented on Mar 12, 2020

    Contributor

    there are two issues here:

    1. The miter_limit is not explicitly set by matplotlib anywhere. Therefore, each backend will end up effectively utilizing whatever the target is (e.g. 4 for SVG, 10 for PostScript and PDF, etc.)
    2. Agg in particular appears to still treat miter limits incorrectly (I can reproduce this issue on 3.1.3).

    So to really deal with this issue, it looks like we'd have to actually add a new rcParam (miterlimit), and have each of the backends respect it (including a simple change in _backend_agg.h to force the Agg backend to treat miter limit as relative, as that is the standard everywhere else).

    This bug seems reasonably low priority and high effort? But if I want to correctly handle miter limits in #16607, I would need to add this new rcParam first...

  2. anntzer commented on Mar 12, 2020

    ContributorAuthor

    I agree that this is pretty high effort/low priority (though see #14939)...

  3. github-actions commented on Apr 25, 2023

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  4. anntzer commented on Apr 25, 2023

    ContributorAuthor

    Still true, still low priority.

  5. github-actions commented on Jun 12, 2024

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  6. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL