title: Barplot colored according a colormap?
body: <p>First of all, I'm pretty new to colors in Matplotlib or Seaborn. My purpose is to create a barplot with bars coloured according to a custom palette. Something like this, but with my custom palette (see below, a palette with red, orange, green and blue): </p>
  
  <p><img src="https://i.stack.imgur.com/ixkQj.png" alt="barplot"></p>
  
  <p>I have created my custom sequential palette using the <code>LinearSegmentedColormap</code> method, but I'm not able to use it in a simple <code>plt.barplot()</code>. Sure it's not difficult, but I can't see the way. I created the palette using the function below, got from this thread: <a href="https://stackoverflow.com/questions/16834861/create-own-colormap-using-matplotlib-and-plot-color-scale">Create own colormap using matplotlib and plot color scale</a></p>
  
  <pre><code>def make_colormap(seq):
  """Return a LinearSegmentedColormap
  seq: a sequence of floats and RGB-tuples. The floats should be increasing
  and in the interval (0,1).
  """
  seq = [(None,) * 3, 0.0] + list(seq) + [1.0, (None,) * 3]
  cdict = {'red': [], 'green': [], 'blue': []}
  for i, item in enumerate(seq):
      if isinstance(item, float):
          r1, g1, b1 = seq[i - 1]
          r2, g2, b2 = seq[i + 1]
          cdict['red'].append([item, r1, r2])
          cdict['green'].append([item, g1, g2])
          cdict['blue'].append([item, b1, b2])
  
  return mcolors.LinearSegmentedColormap('CustomMap', cdict)
  
  #main#
  c = mcolors.ColorConverter().to_rgb
  rvb = make_colormap(
  [c('red'), 0.125, c('red'), c('orange'), 0.25, c('orange'),c('green'),0.5, c('green'),0.7, c('green'), c('blue'), 0.75, c('blue')])
  
  N = 1000
  array_dg = np.random.uniform(0, 10, size=(N, 2))
  colors = np.random.uniform(0, 5, size=(N,))
  plt.scatter(array_dg[:, 0], array_dg[:, 1], c=colors, cmap=rvb)
  plt.colorbar()
  plt.show()
  </code></pre>
  
  <p>That returns this plot:</p>
  
  <p><img src="https://i.stack.imgur.com/IPhce.png" alt="plot palette ok"></p>
  
  <p>As far as I can understand, I can't use a colormap (object type from <code>LinearSegmentedColormap()</code>? ) for barplots, but colormap is the unique way I have achieved a custom sequential palette.</p>
  
  <p>In summary, I want to <strong>apply the colormap of the second plot (the scatterplot) to the first plot (the barplot)</strong>. For now I can't do it because the <code>barplot()</code> function has not an argument that accepts a <code>LinearSegmentedColormap</code> object type.</p>
  
  <p>I'm probably making it harder than it really is, so I would appreciate any cleaner or more correct way.</p>