title: create legend manually in matplotlib
body: <p>I have the following code to plot a bar graph - there are 6 species but the code groups them into three coloured groupings.</p>
  
  <p>I then want to make a legend of the three groups with three colours. However, the legend only features the first grouping (which is colored correctly!) and then ignores the other groupings (see image)</p>
  
  <p><a href="https://i.stack.imgur.com/EftNx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EftNx.png" alt="enter image description here"></a></p>
  
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  import numpy as np
  
  #create data frame
  G = pd.DataFrame(np.random.normal(100,20,size=(30, 1)), columns=list('G'))
  T = []
  for i in range(1,7):
      for j in range(5):
          T.append('Species'+repr(i))
  T = pd.DataFrame(np.array(T).reshape(30,1), columns = list("T"))
  cols = ['g','b','k']
  C=[]
  for i in range(3):
      for j in range(10):
          C.append(cols[i])
  C = pd.DataFrame(np.array(C).reshape(30,1), columns = list("C"))
  dat = pd.concat([G, C, T], axis = 1)
  dat.columns = ['growth', 'cols', 'sp']
  
  #begin code to make plot
  grps = sorted(list(set(list(dat['sp']))))
  meanGrs=[]
  sems=[]
  cols=[]
  y_pos = np.arange(len(grps))
  for grp in grps:
      qw = 'sp == "' + grp + '"'
      meanGrs.append(dat.query(qw)['growth'].mean())
      sems.append(dat.query(qw)['growth'].sem())
      cols.append(str(dat.query(qw)['cols'].max()))
  
  plt.bar(y_pos, meanGrs, yerr=sems, align = 'center', alpha = 0.5, color = cols, label = cols)
  plt.legend(('group 1', 'group 2', 'group 3'))
  plt.xticks(y_pos, grps, ha = 'right', rotation = 45)
  plt.show()
  </code></pre>
  
  <p>Any help much appreciated</p>