# TypeError: 'bins'必须是整数、标量序列或字符串，而不是字符串列表。

- **ID:** `python/matplotlib-histogram-bins-error`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

向plt.hist()传递了字符串列表作为bins参数，但该参数需要数值型bins或单个字符串方法（如'auto'、'fd'）。

## 版本兼容性

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

## 解决方案

1. **Use an integer for the number of bins** (95% 成功率)
   ```
   plt.hist(data, bins=20)
   ```
2. **Use a sequence of bin edges as numbers** (90% 成功率)
   ```
   plt.hist(data, bins=[0, 10, 20, 30])
   ```

## 无效尝试

- **Using a list of integers but with mixed types** — Bins must be numeric; mixed types cause conversion errors. (80% 失败率)
- **Passing a single string like 'auto' but in a list** — A list of one string is still a list, not a valid bins argument. (90% 失败率)
