title: Matplotlib Color Gradient based on y-value
body: <p>I would like to plot a "cut" through a heat map, i.e. apply a color gradient to my <code>plt.plot(x,y)</code> based on the y-values (which are in a range of <code>-0.5,0.5</code>.</p>
  
  <p>Any suggestions? I tried to workaround by using a scatter-plot, but the colormap seemed to be applied to each line individually (and not globally).</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT</strong>
  To describe it in other terms: I would like to map each y-value in the interval to an appropriate color in my colormap. (The phrase 'cut through heat map' just refers to the commonly used technique to map the z-values of a function <code>z=f(x,y)</code> for given x and y to a color.)</p>
  
  <p>As mentioned earlier already, just applying a colormap to a scatter-plot seems to to map the maximum y-value of each line (as i am plotting multiple series) to white, as seen in the attachment. Instead, I would like to map the global y=0.5 in my plot to white and -0.5 to black for each line.</p>
  
  <p><a href="https://i.stack.imgur.com/FZayu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FZayu.png" alt="Example"></a></p>