# ValueError: 交互模式必须是布尔值，但得到了'True'（字符串）。

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

## 根因

向plt.ion()或plt.ioff()传递了字符串而非布尔值，或将rcParams['interactive']设置为字符串。

## 版本兼容性

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

## 解决方案

1. **Use plt.ion() to enable interactive mode (no arguments)** (95% 成功率)
   ```
   plt.ion()
   ```
2. **Set rcParams with a boolean** (90% 成功率)
   ```
   plt.rcParams['interactive'] = True
   ```

## 无效尝试

- **Using 1 or 0 instead of True/False** — While 1 and 0 are truthy, they are not booleans; the function expects a bool. (70% 失败率)
- **Setting plt.ion(True) with parentheses** — plt.ion() takes no arguments; it toggles interactive mode on. Passing an argument raises TypeError. (90% 失败率)
