title: (python matplotlib ) How to change color of each lollipop in a lollipop plot (ax.stem)
body: <p>I am using <code>ax.stem</code> to draw lollipop plot in python. However, I found it difficult to assign different colors to each lollipop
  <a href="https://i.stack.imgur.com/veCjH.png" rel="nofollow noreferrer">as shown here</a> </p>
  
  <p>As you can see I have 2 categories "GWP" &amp; "FDP". 
  In my project, each category should be divided into 4 subcategories "ingredient", "Waste", "energy" and "infrastructure". Therefore, I want to assign them different colors to indicate the subcategory. </p>
  
  <p>There is a solution proposed here: <a href="https://python-graph-gallery.com/181-custom-lollipop-plot/" rel="nofollow noreferrer">https://python-graph-gallery.com/181-custom-lollipop-plot/</a></p>
  
  <p>But this only teaches you how to change color for all lollipops. </p>
  
  <p>And there is another solution: <a href="https://python-graph-gallery.com/183-highlight-a-group-in-lollipop/" rel="nofollow noreferrer">https://python-graph-gallery.com/183-highlight-a-group-in-lollipop/</a></p>
  
  <p>But this one doesn't really use <code>ax.stem</code>.</p>
  
  <p>Please let me know how to assign different colors to each lollipop.</p>
  
  <p>(Also, I don't know somehow why my plot is displayed upside down. Also, the y axis does not align in order, and there is one dot not connected by a line. It displays correctly in my original plot though.)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#%%
  import numpy as np
  import pandas as pd
  import matplotlib.pyplot as plt
  
  plt.style.use('ggplot')
  
  
  # my dataset
  columns = np.array(['types', 'GWP100 (year)', 'FDP (year)'])
  
  
  types = np.array(['Total (ingredient) per kg', 'Total (waste) per kg',
         'energy (whole process) per kg', 'Infrastructure', 'Total (Total)']).reshape(5,1)
  gwp = np.array([  2.86982617e+02,   2.16824983e+02,   4.38920760e+01,
           6.02400000e-02,   5.47759916e+02]).reshape(5,1)
  fdp = np.array([  1.35455867e+02,   7.02868322e+00,   1.26622560e+01,
           1.64568000e-02,   1.55163263e+02]).reshape(5,1)
  
  original_data = np.concatenate((types, gwp, fdp), axis = 1)
  
  
  
  
  # produce dataframe
  data = pd.DataFrame(original_data, columns = columns)
  
  #                           types GWP100 (year)  FDP (year)
  #0      Total (ingredient) per kg    286.982617  135.455867
  #1           Total (waste) per kg    216.824983  7.02868322
  #2  energy (whole process) per kg     43.892076   12.662256
  #3                 Infrastructure       0.06024   0.0164568
  #4                  Total (Total)    547.759916  155.163263
  
  
  #%%  graph
  fig = plt.figure(1, figsize =(8,6))
  
  # 1st subplot
  ax1 = fig.add_subplot(1,2,1)
  gwp = data[data.columns[1]]
  
  ax1.stem(gwp)
  ax1.set_ylabel(r'kg CO$_2$-Eq', fontsize=10)
  ax1.set_xlabel('GWP', fontsize=10)
  
  
  # 2nd subplot
  ax2 = fig.add_subplot(1,2,2)
  fdp = data[data.columns[2]]
  
  ax2.stem(fdp)
  ax2.set_ylabel(r'kg oil-Eq', fontsize = 10)
  ax2.set_xlabel('FDP', fontsize=10)
  </code></pre>