{"record":{"id":"970613be8a650800","repo":"matplotlib/matplotlib","slug":"the-number-of-fixedlocator-locations-len-fixed-l","errorCode":null,"errorMessage":"The number of FixedLocator locations ({len(fixed_locator.locs)}), usually from a call to set_ticks, does not match the number of labels ({len(labels)}).","messagePattern":"The number of FixedLocator locations \\((.+?)\\), usually from a call to set_ticks, does not match the number of labels \\((.+?)\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/axis.py","lineNumber":2340,"sourceCode":"        try:\n            labels = [t.get_text() if hasattr(t, 'get_text') else t\n                      for t in labels]\n        except TypeError:\n            raise TypeError(f\"{labels=!r} must be a sequence\") from None\n        locator = (self.get_minor_locator() if minor\n                   else self.get_major_locator())\n        if not labels:\n            formatter = mticker.NullFormatter()\n        elif (isinstance(locator, mticker.FixedLocator) or\n              (hasattr(locator, 'base') and\n               isinstance(locator.base, mticker.FixedLocator))):\n            # Also handles locators that wrap a FixedLocator (e.g. RadialLocator).\n            fixed_locator = (locator if isinstance(locator, mticker.FixedLocator)\n                             else locator.base)\n            # Passing [] as a list of labels is often used as a way to\n            # remove all tick labels, so only error for > 0 labels\n            if len(fixed_locator.locs) != len(labels) and len(labels) != 0:\n                raise ValueError(\n                    \"The number of FixedLocator locations\"\n                    f\" ({len(fixed_locator.locs)}), usually from a call to\"\n                    \" set_ticks, does not match\"\n                    f\" the number of labels ({len(labels)}).\")\n            tickd = {loc: lab for loc, lab in zip(fixed_locator.locs, labels)}\n            func = functools.partial(self._format_with_dict, tickd)\n            formatter = mticker.FuncFormatter(func)\n        else:\n            _api.warn_external(\n                 \"set_ticklabels() should only be used with a fixed number of \"\n                 \"ticks, i.e. after set_ticks() or using a FixedLocator. \"\n                 \"Otherwise, ticks may be mislabeled.\")\n            formatter = mticker.FixedFormatter(labels)\n\n        with warnings.catch_warnings():\n            warnings.filterwarnings(\n                \"ignore\",\n                message=\"FixedFormatter should only be used together with FixedLocator\")","sourceCodeStart":2322,"sourceCodeEnd":2358,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/axis.py#L2322-L2358","documentation":"Error \"The number of FixedLocator locations ({len(fixed_locator.locs)}), usually from a call to set_ticks, does not match the number of labels ({len(labels)}).\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/axis.py:2340 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"}