{
  "id": "python/matplotlib-log-scale-nonpositive",
  "signature": "UserWarning: Data has no positive values, and therefore cannot be log-scaled.",
  "signature_zh": "UserWarning: 数据没有正值，因此无法进行对数缩放。",
  "regex": "UserWarning:\\ Data\\ has\\ no\\ positive\\ values,\\ and\\ therefore\\ cannot\\ be\\ log\\-scaled\\.",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "Setting a log scale on an axis whose data contains only zero or negative values.",
  "root_cause_type": "generic",
  "root_cause_zh": "在仅包含零或负值的数据轴上设置对数缩放。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Clipping silently replaces values with the smallest positive number, producing misleading plots.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Shifts the entire distribution and can hide genuinely zero categories.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "ax.set_yscale('symlog', linthresh=1)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "import numpy as np\nmask = data > 0\nax.plot(x[mask], data[mask])\nax.set_yscale('log')",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-11-03",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}