{
  "id": "python/matplotlib-tostring-rgba-deprecated",
  "signature": "AttributeError: 'FigureCanvasAgg' object has no attribute 'tostring_rgb'",
  "signature_zh": "AttributeError: 'FigureCanvasAgg' 对象没有属性 'tostring_rgb'",
  "regex": "AttributeError:\\ 'FigureCanvasAgg'\\ object\\ has\\ no\\ attribute\\ 'tostring_rgb'",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Matplotlib 3.10 removed the deprecated tostring_rgb / tostring_argb methods from canvas objects.",
  "root_cause_type": "generic",
  "root_cause_zh": "Matplotlib 3.10 移除了 canvas 对象上已弃用的 tostring_rgb / tostring_argb 方法。",
  "versions": [
    {
      "version": "3.10",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Pins the project to an unsupported version and breaks other dependencies that require 3.10+.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Returns None and then the downstream code raises a different error.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.94,
      "how": "canvas.draw()\nbuf = canvas.buffer_rgba()\nimport numpy as np\narr = np.asarray(buf)  # (H, W, 4) uint8",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.92,
      "how": "from io import BytesIO\nimport numpy as np\nfrom PIL import Image\nbuf = BytesIO()\nfig.savefig(buf, format='png')\nbuf.seek(0)\narr = np.array(Image.open(buf))",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-12-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}