{
  "id": "python/matplotlib-contour-levels-error",
  "signature": "ValueError: Number of contour levels must be at least 2, got 1.",
  "signature_zh": "ValueError: 等高线级别数必须至少为2，但得到了1。",
  "regex": "ValueError:\\ Number\\ of\\ contour\\ levels\\ must\\ be\\ at\\ least\\ 2,\\ got\\ 1\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Passing a single value for levels parameter in contour/contourf, which requires at least two levels to draw contours.",
  "root_cause_type": "generic",
  "root_cause_zh": "向contour/contourf的levels参数传递了单个值，但绘制等高线至少需要两个级别。",
  "versions": [
    {
      "version": "3.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "3.8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using a negative number of levels",
      "why_fails": "Levels must be positive integers or an array; negative numbers raise a different error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting levels as a string like 'auto'",
      "why_fails": "In some versions, 'auto' is not a valid input; it must be a number or array.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Provide at least two levels as an array",
      "success_rate": 0.95,
      "how": "plt.contour(X, Y, Z, levels=[0, 1, 2])",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use an integer to specify the number of automatically chosen levels",
      "success_rate": 0.9,
      "how": "plt.contour(X, Y, Z, levels=10)  # at least 2",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}