{"record":{"id":"b1cfde02f27b7745","repo":"roboflow/supervision","slug":"color-count-must-be-greater-than-or-equal-to-1","errorCode":null,"errorMessage":"color_count must be greater than or equal to 1","messagePattern":"color_count must be greater than or equal to 1","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/draw/color.py","lineNumber":513,"sourceCode":"            palette_name: Name of the Matplotlib palette.\n            color_count: Number of colors to sample from the palette.\n\n        Returns:\n            A ColorPalette instance.\n\n        Example:\n            ```pycon\n            >>> import supervision as sv\n            >>> sv.ColorPalette.from_matplotlib('viridis', 5)  # doctest: +ELLIPSIS\n            ColorPalette(colors=[Color(r=68, g=1, b=84), Color(r=58, g=82, b=139), ...])\n\n            ```\n\n        ![visualized_color_palette](https://media.roboflow.com/\n        supervision-annotator-examples/visualized_color_palette.png)\n        \"\"\"\n        if color_count < 1:\n            raise ValueError(\"color_count must be greater than or equal to 1\")\n\n        # Keep pyplot lazy so importing color utilities does not import matplotlib.\n        import matplotlib.pyplot as plt\n\n        mpl_palette = plt.get_cmap(palette_name)\n        if hasattr(mpl_palette, \"resampled\"):\n            mpl_palette = mpl_palette.resampled(color_count)\n\n        if hasattr(mpl_palette, \"colors\"):\n            colors = mpl_palette.colors\n        else:\n            # A single color samples the palette start and avoids division by zero.\n            positions = (\n                [0.0]\n                if color_count == 1\n                else [i / (color_count - 1) for i in range(color_count)]\n            )\n            colors = [mpl_palette(position) for position in positions]","sourceCodeStart":495,"sourceCodeEnd":531,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/draw/color.py#L495-L531","documentation":"Error \"color_count must be greater than or equal to 1\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/draw/color.py:513 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Request at least one color when generating a palette (color_count >= 1).","Guard the call so color_count is never zero or negative."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}