2

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?

Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • Possible duplicate of [Pyplot: vertical gradient fill under curve?](http://stackoverflow.com/questions/22081361/pyplot-vertical-gradient-fill-under-curve) – pingul Mar 30 '17 at 15:45
  • 2
    No, it's not possible. You need to use some workaround like the one you already have or using an image that is clipped. – ImportanceOfBeingErnest Mar 30 '17 at 16:07

0 Answers0