title: matplotlib colorbar for scatter
body: <p>I'm working with data that has the data has 3 plotting parameters: x,y,c. How do you create a custom color value for a scatter plot? </p>
  
  <p>Extending this <a href="https://stackoverflow.com/questions/2925806/fixing-color-in-scatter-plots-in-matplotlib">example</a> I'm trying to do:</p>
  
  <pre><code>import matplotlib
  import matplotlib.pyplot as plt
  cm = matplotlib.cm.get_cmap('RdYlBu')
  colors=[cm(1.*i/20) for i in range(20)]
  xy = range(20)
  plt.subplot(111)
  colorlist=[colors[x/2] for x in xy] #actually some other non-linear relationship
  plt.scatter(xy, xy, c=colorlist, s=35, vmin=0, vmax=20)
  plt.colorbar()
  plt.show()
  </code></pre>
  
  <p>but the result is <code>TypeError: You must first set_array for mappable</code></p>