用 `pyplot.fill_between` 用两种颜色孵化一个区域
Hatch an area in two colors with `pyplot.fill_between`
我在一些图表之间有一个红色和一个蓝色区域。在这两个区域重叠的地方,我希望该区域用红色和蓝色阴影,即红色和蓝色条纹(如图所示,但蓝色和红色而不是白色和红色)。所以我想通过颜色代码将两种颜色传递给函数。 matplotlib.pyplot.fill_between
这可能吗?或者我该怎么做?
您需要将 hatch
参数添加到 fill_between
的函数调用中
由于您没有提供示例,它看起来像这样:
plt.fill_between(x, a3, a4, color='green',
alpha=0.5,hatch=r"//")
根据您对“对半”影线的要求,您需要在脚本顶部放置类似这样的内容,覆盖影线的默认线宽:
import matplotlib.pyplot as plt
plt.rc('hatch', color='k', linewidth=5)
根据需要调整线宽。
matplotlib.pyplot.fill_between
这可能吗?或者我该怎么做?
您需要将 hatch
参数添加到 fill_between
由于您没有提供示例,它看起来像这样:
plt.fill_between(x, a3, a4, color='green',
alpha=0.5,hatch=r"//")
根据您对“对半”影线的要求,您需要在脚本顶部放置类似这样的内容,覆盖影线的默认线宽:
import matplotlib.pyplot as plt
plt.rc('hatch', color='k', linewidth=5)
根据需要调整线宽。