I want to use fill_between
in order to highlight stress levels.
My current solution to visualize this is:
for i in range(len(u)-1):
x = u[i]
x1 = i
x2 = i+1
off = idxvec[0] + offset
stress = ((u[i] - l[i])/40)**2.
ranges.append(stress)
ax1.fill_between([off+i, off+i+1], [u[i], u[i+1]], [l[i], l[i+1]], alpha=stress, facecolor='red')
which means I set the alpha
value for each slice individually as I scan over my data.
However, this is slow and ugly. Is there a way to do this faster/nicer?
I imagine something like a list
of alpha values that I provide fill_between
and the result is a horizontal gradient:
ax1.fill_between(x, y1, y2, alpha=[0.2, 0.3, ..., 0.4, 0.3])
Is this possible?