title: Plotting a line where each segment has different attributes
body: <p>I've created an animation in matplotlib which is fundamentally a dot that moves around the grid in a chaotic fashion. The current dot is followed with a tail of its previous N locations. Right now, the tail is plotted in a solid color but what I'd like to do is plot it with each of its N segments having an opacity diminished a little bit from the previous segment such that, at the end of tail, the color has almost faded completely away.</p>
  
  <p>It doesn't appear that the plot function allows multiple colors to be passed to it to be applied in a sequential manner to each segment but, is there another way to accomplish this not involving making separate plot calls for every segment, each with a different opacity setting for the color?</p>
  
  <p>This is the core animation function that is called for every frame. I'm setting the tail to a different color every 10 frames. The colors simply cycle through a range of 5 different colors.</p>
  
  <pre><code>def animate(i):
      ip1 = i + 1
      thisx = [0, x1[i], x2[i]]
      thisy = [0, y1[i], y2[i]]
      phi1 = 180.0 * math.atan2(y1[i],x1[i])/math.pi
      phi2 = 180.0 * math.atan2(y2[i],x2[i])/math.pi
  
      line.set_data(thisx, thisy)
  
      x = x2[i-1:max(0,i-20):-1]
      y = y2[i-1:max(0,i-20):-1]
      tail.set_data(x, y)
  
      text = ('\n').join( [
          time_template%(i*dt),
          'Phi 1 = %6.1f deg' % phi1,
          'Phi 2 = %6.1f deg' % phi2 ] )
  
      time_text.set_text(text)
      if (ip1)%10 == 0:
          tail.set_color(next(g_tail_colors))
      return line, time_text, tail
  </code></pre>
  
  <p>Here is one frame of the animation</p>
  
  <p><a href="https://i.stack.imgur.com/xnJjx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xnJjx.png" alt="enter image description here"></a></p>