# ValueError: xlim必须是包含两个数字的序列，但得到了[0, 10, 20]

- **ID:** `python/matplotlib-axes-limits-error`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

向set_xlim()或xlim参数传递了包含两个以上元素的列表。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |

## 解决方案

1. **Use a two-element sequence** (95% 成功率)
   ```
   ax.set_xlim([0, 10])  # or (0, 10)
   ```
2. **Set min and max separately** (90% 成功率)
   ```
   ax.set_xlim(left=0, right=10)
   ```

## 无效尝试

- **Passing a tuple of three numbers** — A tuple with three elements also fails; only two-element sequences are allowed. (90% 失败率)
- **Using xlim=(0,10,20) as keyword argument** — Same issue; xlim expects exactly two values. (85% 失败率)
