{"record":{"id":"5f8e60afadadb8e2","repo":"matplotlib/matplotlib","slug":"z-array-must-have-same-length-as-triangulation-x-a","errorCode":null,"errorMessage":"z array must have same length as triangulation x and y arrays","messagePattern":"z array must have same length as triangulation x and y arrays","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/tri/_tricontour.py","lineNumber":59,"sourceCode":"            self._mins = args[0]._mins\n            self._maxs = args[0]._maxs\n        else:\n            from matplotlib import _tri\n            tri, z = self._contour_args(args, kwargs)\n            C = _tri.TriContourGenerator(tri.get_cpp_triangulation(), z)\n            self._mins = [tri.x.min(), tri.y.min()]\n            self._maxs = [tri.x.max(), tri.y.max()]\n\n        self._contour_generator = C\n        return kwargs\n\n    def _contour_args(self, args, kwargs):\n        tri, args, kwargs = Triangulation.get_from_args_and_kwargs(*args,\n                                                                   **kwargs)\n        z, *args = args\n        z = np.ma.asarray(z)\n        if z.shape != tri.x.shape:\n            raise ValueError('z array must have same length as triangulation x'\n                             ' and y arrays')\n\n        # z values must be finite, only need to check points that are included\n        # in the triangulation.\n        z_check = z[np.unique(tri.get_masked_triangles())]\n        if np.ma.is_masked(z_check):\n            raise ValueError('z must not contain masked points within the '\n                             'triangulation')\n        if not np.isfinite(z_check).all():\n            raise ValueError('z array must not contain non-finite values '\n                             'within the triangulation')\n\n        z = np.ma.masked_invalid(z, copy=False)\n        self.zmax = float(z_check.max())\n        self.zmin = float(z_check.min())\n        if self.logscale and self.zmin <= 0:\n            func = 'contourf' if self.filled else 'contour'\n            raise ValueError(f'Cannot {func} log of negative values.')","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/tri/_tricontour.py#L41-L77","documentation":"Error \"z array must have same length as triangulation x and y arrays\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/tri/_tricontour.py:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}