{"record":{"id":"08eba18907087e4d","repo":"matplotlib/matplotlib","slug":"input-array-must-be-in-the-range-0-1-found-a-m-08eba1","errorCode":null,"errorMessage":"Input array must be in the range [0, 1]. Found a minimum value of {arr.min()}","messagePattern":"Input array must be in the range \\[0, 1\\]\\. Found a minimum value of (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/colors.py","lineNumber":3685,"sourceCode":"                         f\"shape {arr.shape} was found.\")\n\n    in_shape = arr.shape\n    # ensure numerics are done at least on float32; ints are cast as well\n    arr = np.asarray(arr, dtype=np.promote_types(arr.dtype, np.float32))\n    if arr.ndim == 1:\n        arr = np.expand_dims(arr, axis=0)  # ensure arr is 2D\n\n    out = np.zeros_like(arr)\n    arr_max = arr.max(-1)\n    # Check if input is in the expected range\n    if np.any(arr_max > 1):\n        raise ValueError(\n            \"Input array must be in the range [0, 1]. \"\n            f\"Found a maximum value of {arr_max.max()}\"\n        )\n\n    if arr.min() < 0:\n        raise ValueError(\n            \"Input array must be in the range [0, 1]. \"\n            f\"Found a minimum value of {arr.min()}\"\n        )\n\n    ipos = arr_max > 0\n    delta = np.ptp(arr, -1)\n    s = np.zeros_like(delta)\n    s[ipos] = delta[ipos] / arr_max[ipos]\n    ipos = delta > 0\n    # red is max\n    idx = (arr[..., 0] == arr_max) & ipos\n    out[idx, 0] = (arr[idx, 1] - arr[idx, 2]) / delta[idx]\n    # green is max\n    idx = (arr[..., 1] == arr_max) & ipos\n    out[idx, 0] = 2. + (arr[idx, 2] - arr[idx, 0]) / delta[idx]\n    # blue is max\n    idx = (arr[..., 2] == arr_max) & ipos\n    out[idx, 0] = 4. + (arr[idx, 0] - arr[idx, 1]) / delta[idx]","sourceCodeStart":3667,"sourceCodeEnd":3703,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/colors.py#L3667-L3703","documentation":"Error \"Input array must be in the range [0, 1]. Found a minimum value of {arr.min()}\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/colors.py:3685 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"}