{
  "id": "python/matplotlib-tick-label-overlap",
  "signature": "UserWarning: FixedFormatter should only be used together with FixedLocator",
  "signature_zh": "UserWarning: FixedFormatter 只应与 FixedLocator 一起使用。",
  "regex": "UserWarning:\\ FixedFormatter\\ should\\ only\\ be\\ used\\ together\\ with\\ FixedLocator",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Calling set_xticklabels() with a FixedFormatter while the locator is still an auto locator, causing labels to be mismatched with tick positions.",
  "root_cause_type": "generic",
  "root_cause_zh": "在定位器仍为自动定位器时调用 set_xticklabels() 并使用 FixedFormatter，导致标签与刻度位置不匹配。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Labels may still be placed at wrong positions, producing a misleading plot.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The mismatch remains; the warning is informational about the locator/formatter pair.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "import numpy as np\nax.set_xticks(np.arange(len(labels)))\nax.set_xticklabels(labels, rotation=45, ha='right')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from matplotlib.ticker import FuncFormatter\nax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: labels[int(x)] if 0 <= int(x) < len(labels) else ''))",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}