# AttributeError: 'NoneType'对象没有属性'plot'

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

## 根因

在值为None的变量上调用ax.plot()，通常是因为plt.subplots()调用不正确或未正确提取坐标轴对象。

## 版本兼容性

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

## 解决方案

1. **Ensure plt.subplots() returns two values and unpack correctly** (95% 成功率)
   ```
   fig, ax = plt.subplots(); ax.plot([1,2,3])
   ```
2. **Check if ax is None before plotting** (90% 成功率)
   ```
   fig, ax = plt.subplots(); if ax is not None: ax.plot([1,2,3])
   ```

## 无效尝试

- **Checking if the variable name is misspelled** — The issue is not a typo but that the function returned None; misspelling would raise NameError. (60% 失败率)
- **Reinstalling matplotlib** — This is a code logic error, not a library installation issue. (95% 失败率)
