# TypeError: 'figsize'是<class 'matplotlib.figure.Figure'>的无效关键字参数

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

## 根因

将figsize直接传递给plt.figure()是正确的，但如果用户错误地将其传递给子图函数如plt.subplot()或plt.subplots()，则会引发TypeError，因为这些函数不接受figsize。

## 版本兼容性

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

## 解决方案

1. **Pass figsize only to plt.figure() or plt.subplots()** (95% 成功率)
   ```
   fig, ax = plt.subplots(figsize=(8,6))
   ```
2. **Use set_size_inches() on the figure object after creation** (90% 成功率)
   ```
   fig = plt.figure(); fig.set_size_inches(8,6)
   ```

## 无效尝试

- **Using figsize as a positional argument** — figsize must be a keyword argument; positional passing will be misinterpreted. (80% 失败率)
- **Setting plt.rcParams['figure.figsize'] before creating figure** — This changes default figure size, but the error is about passing figsize to wrong function. (70% 失败率)
