我有一个似乎很简单的问题,可能有一个更复杂的解决方案。如何在两行之间渐变阴影?例如。如果我在x=10
和x=20
处有两条垂直线,我该如何从x=10
处的蓝色开始并在x=20
处褪成白色?我知道我可以在中间使用填充色,但是我不知道如何使它渐变。
更新:
到目前为止,我有以下工作代码
import matplotlib as plt
gradmax=20 # value where white starts
gradmin=10 # value where brown starts
grad_num=10 # how many vertical profiles I use, increase for smoothness
axstep=(gradmax-gradmin)/grad_num
alpha_max=0.5
alpha_min=0
alphastep=(alpha_max-alpha_min)/grad_num
fig = plt.figure()
ax=fig.add_subplot()
for i in range(grad_num):
minplot = gradmin+i*axstep
maxplot = gradmin+(i+1)*axstep
alphaplot = alpha_max-alphastep*(i+1)
ax.axvspan(minplot, maxplot, color='brown', edgecolor="None", alpha=alphaplot)
fig.show()
我的问题是线条重叠的地方有垂直条纹。有关如何解决此问题的任何想法?我已经尝试过应用微小的偏移量增量,但这没用。