Bug summary
When a Path contains one or more NaN vertices along with valid vertices, Path.get_extents() returns an all-NaN Bbox. As a result, a single NaN vertex causes the entire bounding box to become invalid, even though the remaining vertices are valid.
I expected the bounding box to be computed from the valid vertices instead.
Code for reproduction
import numpy as np
from matplotlib.path import Path
verts = np.array([
[1, 1],
[np.nan, np.nan],
[2, 2],
])
path = Path(verts)
print(path.get_extents())
Actual outcome
Bbox(x0=nan, y0=nan, x1=nan, y1=nan)
Expected outcome
I expected the bounding box to be computed from the valid vertices, resulting in a bounding box covering (1, 1) to (2, 2).
i.e Bbox(x0=1.0, y0=1.0, x1=2.0, y1=2.0)
Additional information
Path.iter_segments() defaults to remove_nans=True, treating NaN vertices as missing points during iteration. Since Path.get_extents() computes the bounding box for the same path, I expected it to handle NaN vertices consistently.
Operating system
Ubuntu 24.04
Matplotlib Version
3.12.0.dev229+g1e6bcafd1
Matplotlib Backend
tkagg
Python version
3.12.3
Jupyter version
No response
Installation
git checkout
Bug summary
When a
Pathcontains one or more NaN vertices along with valid vertices,Path.get_extents()returns an all-NaNBbox. As a result, a single NaN vertex causes the entire bounding box to become invalid, even though the remaining vertices are valid.I expected the bounding box to be computed from the valid vertices instead.
Code for reproduction
Actual outcome
Bbox(x0=nan, y0=nan, x1=nan, y1=nan)
Expected outcome
I expected the bounding box to be computed from the valid vertices, resulting in a bounding box covering (1, 1) to (2, 2).
i.e Bbox(x0=1.0, y0=1.0, x1=2.0, y1=2.0)
Additional information
Path.iter_segments()defaults toremove_nans=True, treatingNaNvertices as missing points during iteration. SincePath.get_extents()computes the bounding box for the same path, I expected it to handleNaNvertices consistently.Operating system
Ubuntu 24.04
Matplotlib Version
3.12.0.dev229+g1e6bcafd1
Matplotlib Backend
tkagg
Python version
3.12.3
Jupyter version
No response
Installation
git checkout