这个错误提示表明 `failure_time` 变量未定义。这可能是因为您在调用 `calculate_composite_index` 函数时没有正确地获取返回值。
请检查您的代码,确保在调用 `calculate_composite_index` 函数时,已经正确地获取了函数返回的两个值:`composite_index` 和 `failure_time`。例如:
```python
composite_index, failure_time = calculate_composite_index(data, weights)
```
如果您已经正确地获取了返回值,请检查一下 `ax2.axvline(x=failure_time, color=color, linestyle='--')` 这行代码是否在 `calculate_composite_index` 函数之后执行。如果是,请将其移动到函数调用之后。