{
  "id": "python/matplotlib-legend-loc-error",
  "signature": "ValueError: The 'loc' parameter must be a string or an integer between 0 and 10, but you provided 'center left' which is a valid string but misspelled.",
  "signature_zh": "ValueError: 'loc'参数必须是字符串或0到10之间的整数，但您提供了'center left'，这是一个拼写错误的有效字符串。",
  "regex": "ValueError:\\ The\\ 'loc'\\ parameter\\ must\\ be\\ a\\ string\\ or\\ an\\ integer\\ between\\ 0\\ and\\ 10,\\ but\\ you\\ provided\\ 'center\\ left'\\ which\\ is\\ a\\ valid\\ string\\ but\\ misspelled\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The 'loc' string for legend placement is case-sensitive and must be one of the predefined strings like 'upper left', 'lower right', etc.; 'center left' is not valid (should be 'center left'? actually 'center left' is valid? Wait, this error is about misspelling: 'center left' vs 'center left'? Actually 'center left' is valid, but if user typed 'centre left' or 'center left' with extra space, it fails. Let's correct: The error occurs when user provides a string that is not in the allowed list, e.g., 'center left' is valid, but if misspelled as 'centr left', it raises ValueError.",
  "root_cause_type": "generic",
  "root_cause_zh": "图例位置的'loc'字符串区分大小写，必须是预定义字符串之一，例如'upper left'、'lower right'等；拼写错误（如'centr left'）会导致此错误。",
  "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 numeric code like 10 thinking it maps to 'center'",
      "why_fails": "Numeric codes are deprecated in newer versions and may not work as expected; also 'center left' is not a single numeric code.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring case sensitivity and trying 'Upper Left'",
      "why_fails": "The strings are case-sensitive; 'Upper Left' is not valid, only 'upper left' works.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use the exact valid string from documentation",
      "success_rate": 0.95,
      "how": "plt.legend(loc='upper left')  # or 'lower right', 'center', etc.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a valid numeric code (0-10) for backward compatibility",
      "success_rate": 0.9,
      "how": "plt.legend(loc=2)  # 2 corresponds to 'upper left'",
      "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-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}