为具有不同xaxis比例的图形填充重叠绘图区域

2024-09-28 03:16:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用不同的x轴比例填充两个图形的重叠区域

这可以通过使用诸如fill_betweenx()之类的内置函数来实现吗

fig, axs = plt.subplots(1, 2, sharey=True)
...
axs[1].set_xlim(propertyArray[0])
axs[1].plot(redData, y, '-r', linewidth=0.5)
axs2 = axs[2].twiny()
axs2.set_xlim(propertyArray[1])
axs2.plot(blueData, y, '-b', linewidth=0.5)
axs[1].fill_between(y, redData, blueData, where=redData <= blueData, interpolate=True)

使用上面代码的当前结果。https://i.imgur.com/Q8LoUyF.png

所需的结果是基于重叠截面填充,而不是基于值https://i.imgur.com/GrtJf6n.png


Tags: httpscomtrueplotpngfillsetimgur

热门问题