{
  "id": "python/matplotlib-tick-label-rotation-error",
  "signature": "TypeError: rotation must be a number or string, not a list",
  "signature_zh": "TypeError: rotation必须是数字或字符串，而不是列表",
  "regex": "TypeError:\\ rotation\\ must\\ be\\ a\\ number\\ or\\ string,\\ not\\ a\\ list",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Passing a list of rotation values to set_xticklabels() or similar, which expects a single value for all labels or a list of labels with a scalar rotation.",
  "root_cause_type": "generic",
  "root_cause_zh": "向set_xticklabels()等函数传递了旋转值列表，但该函数期望为所有标签设置一个标量值，或为标签列表配合标量旋转。",
  "versions": [
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.9",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using a tuple instead of a list",
      "why_fails": "Tuples are also not accepted; rotation must be a scalar.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting rotation via rcParams for all ticks",
      "why_fails": "This changes default but doesn't fix the TypeError from passing a list.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a scalar rotation value",
      "success_rate": 0.95,
      "how": "ax.set_xticklabels(labels, rotation=45)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Apply rotation individually using a loop",
      "success_rate": 0.9,
      "how": "for label in ax.get_xticklabels(): label.set_rotation(45)",
      "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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-04-15",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}