Matplotlib的线条和填充颜色因Alpha设置而不同

时间:2018-07-18 07:53:58

标签: matplotlib colors fill

xValues1 = np.linspace(-5, 5, 5000)
xValues2 = np.linspace(-5, 5, 5000)

yValues1 = -xValues1**2 + 10
yValues2 = -xValues2**2 + 18

plt.ylim(0,20)

plt.plot(xValues1, yValues1, color='green', linewidth=5, alpha=0.5)
plt.plot(xValues2, yValues2, color='cyan', linewidth=5, alpha=0.5)


plt.fill_between(xValues1, yValues1, color='green', alpha=0.5)
plt.fill_between(xValues2, yValues2, color='cyan', alpha=0.5)

产生this plot where the colors of the line and fill are different.

我该如何补救?

1 个答案:

答案 0 :(得分:0)

这是由于行号。尝试使用两个plt.plot函数:

linewidth=0