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

Clipping filled paths in vector outputs · Issue #9488 · matplotlib/matplotlib · GitHub

Repository navigation

Clipping filled paths in vector outputs #9488

Open

Description

The svg spec says that renderers should support values within the range of a C float (https://www.w3.org/TR/SVG/types.html#Precision). However, in practice, inkscape appears to be limited to overflow around 2**24, probably due to the fact that it relies on cairo (which has the same limitation) for rendering. Chromium's svg renderer also appears to hit an overflow somewhere (not sure about the exact value). Agg also has this limitation (see comment at the top of _path_converters.h:

PathClipper: Clips line segments to a given rectangle. This is
helpful for data reduction, and also to avoid a limitation in
Agg where coordinates can not be larger than 24-bit signed
integers.

and it is explicitly tested that this is worked around for Agg (test_simplification.test_overflow).

Currently, the svg backend clips output paths to the actually drawn canvas, but does not clip filled areas. So, with

from pylab import *
fill_between([0, 1e10], [1, 1], color="b")
plot([0, 1e10], [.5, .5], "r")
gca().set(xlim=(0, 1))  # force very large x-coordinates in pixels
gca().set_axis_off()
savefig("/tmp/foo.png")
savefig("/tmp/foo.svg")

we get:

png:

svg, converted to png by inkscape (can't attach a svg in a gh comment) -- but chromium renders the same way:

(the red line is drawn accurately because it is clipped in the SVG output; the blue box disappears because it is not clipped and overflows inkscape's renderer)

There are similar overflow issues with pdf output (via ghostscript -- the relevant renderer, as we use it for the test suite), which are in fact the factor limiting the clip value in #9477 (that's how I found out about this issue), although I can't point to anything in the pdf spec right now.

Now one may argue that "this is the fault of the noncompliant renderer", but given that we are already clipping unfilled paths, and also fully working around this for raster output, I think it makes sense to clip filled paths as well in svg (and pdf). (Of course, this will still fail when someone tries to make a svg image with a dimension exceeding 2**24. Honestly I don't care about that case :-))

Related to #8901 (clipping in eps).

Activity

  1. added this to the milestone on Oct 21, 2017
  2. tacaswell commented on Oct 21, 2017

    Member

    iirc the reason that we do not clip filled regions is to avoid having to do the computational geometry required.

  3. modified the milestones: , on Feb 14, 2018
  4. anntzer commented on Feb 14, 2018

    ContributorAuthor
  5. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  6. modified the milestones: v3.1.0, v3.2.0 on Mar 18, 2019
  7. github-actions commented on Apr 21, 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!

  8. anntzer commented on Apr 21, 2023

    ContributorAuthor

    Would still be nice to have, I think.

  9. github-actions commented on May 29, 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!

  10. added
    keepItems to be ignored by the “Stale” Github Action
    and removed
    status: inactiveMarked by the “Stale” Github Action
    on May 29, 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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL