我有一个线图和 2 条 hlines,都使用不同的颜色,我正在用 hline 的颜色填充主线与 hlines 交叉的区域。除此之外,我想对这些区域的主线使用相同的颜色。简而言之,当前输出:

以及我目前使用的相关代码:
lower, upper = 20, 80
self.indicatorPlot.axhline(lower, color="red")
self.indicatorPlot.axhline(upper, color="green")
self.indicatorPlot.plot(self.chartTimes, self.indicatorData, color="blue")
self.indicatorPlot.fill_between(self.chartTimes, self.indicatorData, lower, where=(self.indicatorData <= lower), facecolor="red", interpolate=True)
self.indicatorPlot.fill_between(self.chartTimes, self.indicatorData, upper, where=(self.indicatorData >= upper), facecolor="green", interpolate=True)
Run Code Online (Sandbox Code Playgroud)