{"record":{"id":"8e28edcaf8f69c1d","repo":"matplotlib/matplotlib","slug":"the-colorizer-keyword-cannot-be-used-simultaneou","errorCode":null,"errorMessage":"The `colorizer` keyword cannot be used simultaneously with any of the following keywords: {keys}","messagePattern":"The `colorizer` keyword cannot be used simultaneously with any of the following keywords: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/colorizer.py","lineNumber":653,"sourceCode":"            mask = np.any(mask.view('bool').reshape((*A.shape, -1)), axis=-1)\n        return mask\n\n    def changed(self):\n        \"\"\"\n        Call this whenever the mappable is changed to notify all the\n        callbackSM listeners to the 'changed' signal.\n        \"\"\"\n        self.callbacks.process('changed', self)\n        self.stale = True\n\n    @staticmethod\n    def _check_exclusionary_keywords(colorizer, **kwargs):\n        \"\"\"\n        Raises a ValueError if any kwarg is not None while colorizer is not None\n        \"\"\"\n        if colorizer is not None:\n            if any([val is not None for val in kwargs.values()]):\n                raise ValueError(\"The `colorizer` keyword cannot be used simultaneously\"\n                                 \" with any of the following keywords: \"\n                                 + \", \".join(f'`{key}`' for key in kwargs.keys()))\n\n    @staticmethod\n    def _get_colorizer(cmap, norm, colorizer):\n        if isinstance(colorizer, Colorizer):\n            _ScalarMappable._check_exclusionary_keywords(\n                Colorizer, cmap=cmap, norm=norm\n            )\n            return colorizer\n        return Colorizer(cmap, norm)\n\n# The docstrings here must be generic enough to apply to all relevant methods.\nmpl._docstring.interpd.register(\n    cmap_doc=\"\"\"\\\ncmap : str or `~matplotlib.colors.Colormap`, default: :rc:`image.cmap`\n    The Colormap instance or registered colormap name used to map scalar data\n    to colors.\"\"\",","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/colorizer.py#L635-L671","documentation":"The colorizer= keyword bundles a ready-made Colorizer (cmap + norm as a unit). It is intentionally exclusive: supplying it together with cmap=, norm= (or similar configuration keywords) makes the configuration ambiguous, so _check_exclusionary_keywords raises this ValueError listing the conflicting keys.","triggerScenarios":"ax.imshow(data, colorizer=cz, norm=nrm); plt.pcolormesh(..., colorizer=cz, cmap='viridis'); any ScalarMappable-creating API receiving colorizer alongside cmap/norm/vmin-like config kwargs.","commonSituations":"Gradually migrating code to the colorizer API while old kwargs remain in a shared defaults dict; wrapper functions that merge user kwargs with preset kwargs and forward everything.","solutions":["Pass colorizer alone and move all styling into the Colorizer at construction","Or drop colorizer and configure with cmap=/norm= individually","In merged-kwargs wrappers, pop cmap/norm when colorizer is present before calling"],"exampleFix":"// before\nax.imshow(data, colorizer=cz, norm=nrm)\n// after\nax.imshow(data, colorizer=cz)  // norm already inside cz\n// or\nax.imshow(data, norm=nrm)  // let matplotlib build the colorizer","handlingStrategy":"validation","validationCode":"if colorizer is not None:\n    cmap = norm = None  # or: kwargs.pop('cmap', None); kwargs.pop('norm', None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When merging preset kwargs with user kwargs, pop cmap/norm if colorizer survives the merge","Treat colorizer as the single source of truth once adopted — delete per-channel styling keys"],"tags":["matplotlib","colorizer","parameter-conflict","kwargs"],"backgroundTag":"mutually-exclusive-parameters","analyzedSha":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}