{"record":{"id":"492fd14ad1537692","repo":"matplotlib/matplotlib","slug":"rgba-values-should-be-within-0-1-range","errorCode":null,"errorMessage":"RGBA values should be within 0-1 range","messagePattern":"RGBA values should be within 0-1 range","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/colors.py","lineNumber":442,"sourceCode":"        if c.ndim == 2 and c.shape[0] == 1:\n            c = c.reshape(-1)\n    # tuple color.\n    if not np.iterable(c):\n        raise ValueError(f\"Invalid RGBA argument: {orig_c!r}\")\n    if len(c) not in [3, 4]:\n        raise ValueError(\"RGBA sequence should have length 3 or 4\")\n    if not all(isinstance(x, Real) for x in c):\n        # Checks that don't work: `map(float, ...)`, `np.array(..., float)` and\n        # `np.array(...).astype(float)` would all convert \"0.5\" to 0.5.\n        raise ValueError(f\"Invalid RGBA argument: {orig_c!r}\")\n    # Return a tuple to prevent the cached value from being modified.\n    c = tuple(map(float, c))\n    if len(c) == 3 and alpha is None:\n        alpha = 1\n    if alpha is not None:\n        c = c[:3] + (alpha,)\n    if any(elem < 0 or elem > 1 for elem in c):\n        raise ValueError(\"RGBA values should be within 0-1 range\")\n    return c\n\n\ndef to_rgba_array(c, alpha=None):\n    \"\"\"\n    Convert *c* to a (n, 4) array of RGBA colors.\n\n    Parameters\n    ----------\n    c : :mpltype:`color` or list of :mpltype:`color` or RGB(A) array\n        If *c* is a masked array, an `~numpy.ndarray` is returned with a\n        (0, 0, 0, 0) row for each masked value or row in *c*.\n\n    alpha : float or sequence of floats, optional\n        If *alpha* is given, force the alpha value of the returned RGBA tuple\n        to *alpha*.\n\n        If None, the alpha value from *c* is used. If *c* does not have an","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/colors.py#L424-L460","documentation":"Error \"RGBA values should be within 0-1 range\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/colors.py:442 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"}