From 0c6b40ca44b6a10e9aba090cc1a3e0144d31a083 Mon Sep 17 00:00:00 2001 From: "shuwen.wu" Date: Wed, 2 Sep 2026 19:43:30 +0800 Subject: [PATCH] fix: initialize ragged Poly3DCollection padding with NaN Replace np.empty() with np.full(..., np.nan) when creating padded storage for ragged polygons. Previously uninitialized padding could contain arbitrary values that caused overflow in projection. Fixes #32272 --- lib/mpl_toolkits/mplot3d/art3d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mpl_toolkits/mplot3d/art3d.py b/lib/mpl_toolkits/mplot3d/art3d.py index b0d7312bff3d..21e134ef5e50 100644 --- a/lib/mpl_toolkits/mplot3d/art3d.py +++ b/lib/mpl_toolkits/mplot3d/art3d.py @@ -1360,7 +1360,7 @@ def _get_vector(self, segments3d): num_faces = len(segments3d) num_verts = np.fromiter(map(len, segments3d), dtype=np.intp) max_verts = num_verts.max(initial=0) - segments = np.empty((num_faces, max_verts, 3)) + segments = np.full((num_faces, max_verts, 3), np.nan) for i, face in enumerate(segments3d): segments[i, :len(face)] = face self._faces = segments