Skip to content

Computing the bounding box of a degenerate polygon throws an error #17975

@antonio-rojas

Description

@antonio-rojas

With 3.3.0, computing the bounding box of a degenerate (one-point) polygon throws an error

Code for reproduction

from matplotlib.patches import Polygon                                                                                                            
pp=Polygon([[0.,0.]])                                                                                                                             
pp.get_extents()                                                                                                                                  

Actual outcome

ValueError                                Traceback (most recent call last)
<ipython-input-3-1312a177eac2> in <module>
----> 1 pp.get_extents()

/usr/lib/python3.8/site-packages/matplotlib/patches.py in get_extents(self)
    254         Return the `Patch`'s axis-aligned extents as a `~.transforms.Bbox`.
    255         """
--> 256         return self.get_path().get_extents(self.get_transform())
    257 
    258     def get_transform(self):

/usr/lib/python3.8/site-packages/matplotlib/path.py in get_extents(self, transform, **kwargs)
    590             self = transform.transform_path(self)
    591         bbox = Bbox.null()
--> 592         for curve, code in self.iter_bezier(**kwargs):
    593             # places where the derivative is zero can be extrema
    594             _, dzeros = curve.axis_aligned_extrema()

/usr/lib/python3.8/site-packages/matplotlib/path.py in iter_bezier(self, **kwargs)
    442             if first_vert is None:
    443                 if code != Path.MOVETO:
--> 444                     raise ValueError("Malformed path, must start with MOVETO.")
    445             if code == Path.MOVETO:  # a point is like "CURVE1"
    446                 first_vert = verts

ValueError: Malformed path, must start with MOVETO.

Expected outcome

With 3.2:

Bbox([[inf, inf], [-inf, -inf]])

Matplotlib version

  • Operating system: Linux x86_64
  • Matplotlib version: 3.3.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.8.4

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy