matplotlib/matplotlib · error · ValueError
triangles are indices into the points and must be in the ran
Error message
triangles are indices into the points and must be in the range 0 <= i < {len(self.x)} but found value {self.triangles.max()} What it means
Error "triangles are indices into the points and must be in the range 0 <= i < {len(self.x)} but found value {self.triangles.max()}" thrown in matplotlib/matplotlib.
Source
Thrown at lib/matplotlib/tri/_triangulation.py:75
if triangles is None:
# No triangulation specified, so use matplotlib._qhull to obtain
# Delaunay triangulation.
self.triangles, self._neighbors = _qhull.delaunay(x, y, sys.flags.verbose)
self.is_delaunay = True
else:
# Triangulation specified. Copy, since we may correct triangle
# orientation.
try:
self.triangles = np.array(triangles, dtype=np.int32, order='C')
except ValueError as e:
raise ValueError('triangles must be a (N, 3) int array, not '
f'{triangles!r}') from e
if self.triangles.ndim != 2 or self.triangles.shape[1] != 3:
raise ValueError(
'triangles must be a (N, 3) int array, but found shape '
f'{self.triangles.shape!r}')
if self.triangles.max() >= len(self.x):
raise ValueError(
'triangles are indices into the points and must be in the '
f'range 0 <= i < {len(self.x)} but found value '
f'{self.triangles.max()}')
if self.triangles.min() < 0:
raise ValueError(
'triangles are indices into the points and must be in the '
f'range 0 <= i < {len(self.x)} but found value '
f'{self.triangles.min()}')
# Underlying C++ object is not created until first needed.
self._cpp_triangulation = None
# Default TriFinder not created until needed.
self._trifinder = None
self.set_mask(mask)
def calculate_plane_coefficients(self, z):View on GitHub (pinned to b379c1b69e)
When it happens
Trigger: Thrown at lib/matplotlib/tri/_triangulation.py:75 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of matplotlib/matplotlib@b379c1b69e (2026-08-21).
Data as JSON: /api/errors/bc3c89b0ef529df5.
Report an issue: GitHub.