# UserWarning: 数据没有正值，因此无法进行对数缩放。

- **ID:** `python/matplotlib-log-scale-nonpositive`
- **领域:** python
- **类别:** data_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在仅包含零或负值的数据轴上设置对数缩放。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (90% 成功率)
   ```
   ax.set_yscale('symlog', linthresh=1)
   ```
2. **** (88% 成功率)
   ```
   import numpy as np
mask = data > 0
ax.plot(x[mask], data[mask])
ax.set_yscale('log')
   ```

## 无效尝试

- **** — Clipping silently replaces values with the smallest positive number, producing misleading plots. (55% 失败率)
- **** — Shifts the entire distribution and can hide genuinely zero categories. (50% 失败率)
