title: How to give a pandas/matplotlib bar graph custom colors
body: <p>I just started using pandas/matplotlib as a replacement for Excel to generate stacked bar charts.  I am running into an issue  </p>
  
  <p>(1) there are only 5 colors in the default colormap, so if I have more than 5 categories then the colors repeat.  How can I specify more colors?  Ideally, a gradient with a start color and an end color, and a way to dynamically generate n colors in between?</p>
  
  <p>(2) the colors are not very visually pleasing.  How do I specify a custom set of n colors?  Or, a gradient would also work.</p>
  
  <p>An example which illustrates both of the above points is below:</p>
  
  <pre><code>  4 from matplotlib import pyplot
    5 from pandas import *
    6 import random
    7 
    8 x = [{i:random.randint(1,5)} for i in range(10)]
    9 df = DataFrame(x)
   10 
   11 df.plot(kind='bar', stacked=True)
  </code></pre>
  
  <p>And the output is this:</p>
  
  <p><img src="https://i.stack.imgur.com/SC7g4.png" alt="enter image description here"></p>