title: How to add error bars in matplotlib for multiple groups from dataframe?
body: <p>I've run multiple regressions and stored the coefficients and standard errors into a data frame like this:</p>
  
  <p><a href="https://i.stack.imgur.com/AhSPV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AhSPV.png" alt="Data frame"></a></p>
  
  <p>I wanted to make a graph that shows how the coefficient changes for each group over time, like so:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import seaborn as sns
  
  plt.figure(figsize=(14,8))
  
  sns.set(style= "whitegrid")
  
  sns.lineplot(x="time", y="coef",
               hue="group",
               data=eventstudy)
  plt.axhline(y=0 , color='r', linestyle='--')
  plt.legend(bbox_to_anchor=(1, 1), loc=2)
  plt.show
  plt.savefig('eventstudygraph.png')
  </code></pre>
  
  <p>Which produces:
  <a href="https://i.stack.imgur.com/XNjQq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XNjQq.png" alt="enter image description here"></a></p>
  
  <p>But I would like to include error bars using the 'stderr' data from my main data set. 
  I think I can do it using 'plt.errorbar'. But can't seem to figure out how to make it work. At the moment, I've tried adding the 'plt.errorbar line and experimenting different with different iterations:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import seaborn as sns
  
  plt.figure(figsize=(14,8))
  
  sns.set(style= "whitegrid")
  
  sns.lineplot(x="time", y="coef",
               hue="group",
               data=eventstudy)
  plt.axhline(y=0 , color='r', linestyle='--')
  plt.errorbar("time", "coef", xerr="stderr", data=eventstudy)
  plt.legend(bbox_to_anchor=(1, 1), loc=2)
  plt.show
  plt.savefig('eventstudygraph.png')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/boB8Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/boB8Q.png" alt="enter image description here"></a></p>
  
  <p>As you can see, it seems to be creating it's own group/line in the graph. I think I would know how to use 'plt.errorbar' if I had just one group, but I don't have a clue how to make it work for 3 groups. Is there some way of making 3 versions of 'plt.errorbar' so I can create the error bars for each group separately? Or is there something simpler?</p>