{
  "id": "python/matplotlib-tight-layout-warning",
  "signature": "UserWarning: Tight layout not applied. The left and right margins cannot be made large enough to accommodate all Axes decorations.",
  "signature_zh": "UserWarning: 未应用紧凑布局。左右边距无法足够大以容纳所有轴装饰。",
  "regex": "UserWarning:\\ Tight\\ layout\\ not\\ applied\\.\\ The\\ left\\ and\\ right\\ margins\\ cannot\\ be\\ made\\ large\\ enough\\ to\\ accommodate\\ all\\ Axes\\ decorations\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "plt.tight_layout() cannot satisfy the requested spacing because of long tick labels, many subplots, or a fixed figure size that leaves no room.",
  "root_cause_type": "generic",
  "root_cause_zh": "由于过长的刻度标签、过多子图或固定的图形尺寸导致没有足够空间，plt.tight_layout() 无法满足所需的间距。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Repeated calls yield the same constraint violation; the layout engine has no additional space to allocate.",
      "fail_rate": 0.92,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides the symptom but the labels are still clipped in the saved figure.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "fig, axs = plt.subplots(2, 2, constrained_layout=True, figsize=(10, 8))\n# or: fig.set_layout_engine('constrained')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "fig, ax = plt.subplots(figsize=(12, 8))\nax.plot([1,2,3])\nplt.tight_layout(pad=2.0)",
      "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-06-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}