title: errorbars & colorbars python
body: <p>I want to plot a scatter plot, that has a colorbar, and the data has errorbars. Here's my code:</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  np.random.seed(123)
  
  x = np.linspace(0.1, 100, 10)
  y = np.linspace(6, 18, 10)
  yerr = np.random.random(10)
  z = np.linspace(0, 10, 10)
  
  plt.scatter(x, y, s = 20, c = z)
  plt.colorbar()
  plt.errorbar(x, y, yerr = yerr, fmt = '.')
  </code></pre>
  <p>Here's the plot:
  <a href="https://i.stack.imgur.com/jqras.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jqras.png" alt="enter image description here" /></a></p>
  <p>However, the errorbars are drawn in blue. I want to draw them according to the colorbar, how can I do this? For example, if a point has a value of <code>10</code> the errorbar should be drawn in <code>red</code>.</p>
  <h2>EDIT</h2>
  <p>Following the answer suggested below, I wrote:</p>
  <pre><code>cmap = matplotlib.cm.get_cmap('jet')
  norm = matplotlib.colors.Normalize(vmin=min(y), vmax=max(y))
  
  plt.scatter(x, y, s = 20, c=z, cmap=cmap)
  plt.colorbar()
  plt.errorbar(x, y, yerr = yerr, fmt = '.', c=cmap(norm(y)))
  </code></pre>
  <p>But still, it didn't work. Any suggestions?</p>
  <p>I am still interested to get an answer to this question. Anyone?</p>