# UserWarning: FixedFormatter 只应与 FixedLocator 一起使用。

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

## 根因

在定位器仍为自动定位器时调用 set_xticklabels() 并使用 FixedFormatter，导致标签与刻度位置不匹配。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   import numpy as np
ax.set_xticks(np.arange(len(labels)))
ax.set_xticklabels(labels, rotation=45, ha='right')
   ```
2. **** (90% 成功率)
   ```
   from matplotlib.ticker import FuncFormatter
ax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: labels[int(x)] if 0 <= int(x) < len(labels) else ''))
   ```

## 无效尝试

- **** — Labels may still be placed at wrong positions, producing a misleading plot. (70% 失败率)
- **** — The mismatch remains; the warning is informational about the locator/formatter pair. (85% 失败率)
