title: Pandas/matplotlib bar chart with colors defined by column
body: <p>I am trying to make a bar chart in python, and color bars by a data frame column, this is exceedingly easy in R ggplot2, so I really do who not understand why it is so hard in matplotlib/pandas, I would like to understand how to do it and hopefully the logic as I assume it can't be hard after all</p>
  
  <p>Here is an example of what I want.  I did in ggplot - all I want is to define the color using attributes in the data frame, the attribute can be the color string i.e. 'k','r' .. or a feature of the data say male/female, etc.
  <img src="https://i.stack.imgur.com/mSu6f.png" alt="enter image description here"></p>
  
  <p>this is an example of code I tried  that works to generate the bars</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import pandas as pd
  data = pd.DataFrame({'name' : ['a','b','c'],'value' : [1,2,3], 
                       'c' : ['b','r','b']})
  data.plot('name','value',kind='bar')
  </code></pre>
  
  <p>but I want the color defined by column 'c'</p>
  
  <p>but when I add color='c' then it does not work</p>
  
  <pre><code>data.plot('name','value',color='c',kind='bar',color='c')
  </code></pre>
  
  <p>I tried using plot.scatter as well and it did not work either</p>
  
  <p>---- Update</p>
  
  <p>I did some more work and this works more or less, I have yet to figure out how to properly align the labels, I still do to like why I have to have a numeric x axis, when it is really categorical (again ggplot2 deals with this on its own) - but ar least this can be done in code</p>
  
  <pre><code>fig, ax = plt.subplots()
  ax.bar(range(len(data)),data['value'],width=.5,color=data['c'])
  ax.set_xticks(range(len(data)))
  ax.set_xticklabels( (data['name'] ))
  </code></pre>
  
  <p>Thanks as always</p>