Answers.Body: <p>I did put forward a comment, it was removed I think the idea is its a full post or zero. The problem proving a negative is tricky.</p>
  <p>I don't think its doable within the exact system specified, i.e. a Seaborn bar chart. Again I could be wrong.</p>
  <p>If the OP went to a Seaborn dot line formation - that would work <code>sns.barplot</code> is changed to <code>sns.pointplot</code> but then all the nice colouring disappears. Standard deviation  is one error range if all the values are present: but I think the OP will need to request it (<code>.sd()</code> ?? can't remember).</p>
  <p>In <code>matplotlib</code> there is an error bar method where the coder specifies the error bars and that is <code>plt.errorbar</code>. An example from the official docs is <a href="https://matplotlib.org/stable/gallery/lines_bars_and_markers/errorbar_limits_simple.html#sphx-glr-gallery-lines-bars-and-markers-errorbar-limits-simple-py" rel="nofollow noreferrer">here</a>. Thus call a bar chart and then add the error bars onto it.</p>
  <p><strong>Summary</strong> The reasons I don't think its doable in Seaborn:</p>
  <ol>
  <li>I'm pretty certain Seaborn has no independent errorbar method unlike matplotlib</li>
  <li>Seaborn can do error bars given the full data set, but those are created automatically for a given method. Maybe there is a &quot;sns.barplot-errorbar&quot; method but I don't know it.</li>
  </ol>
  <p>The Seaborn approach does carry the advantage of not having to work out the error bar independently.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-01T14:41:23.057Z
Answers.LastActivityDate: 2022-08-01T14:54:20.490Z
Answers.LastEditDate: 2022-08-01T14:54:20.490Z
Answers.UserDisplayName: M__
Body: <p>I am using the below code to get the bar plot. I want to get the bar plot with error bars displayed.</p>
  <pre><code>import seaborn as sns
  
  def plot_coefficients(target, coeffs_df, n=10):
      if coeffs_df.shape[0]==0:
          return None # nothing to plot here!
      data = coeffs_df.copy()
      data = data.sort_values(('Coefficient','mean'), ascending=False).head(n)
      g = sns.barplot(
          data=data,
          y='Gene',
          x=('Coefficient','mean'),
          hue='Feature Type',
          hue_order=[
              h for h in [
                  'Genomic Variant',
                  'Gene Expression',
                  'Proteomics',
                  'Methylation',
              ] 
          ],
          dodge=False
      )
      g.set(
          xlim=(0,1),
          xlabel='Importance [0,1]',
          ylabel='',
          title=f&quot;Top {target} predictor features&quot;
      )
      return g
  </code></pre>
  <p>Coefficient here is a score generated from predictive modelling that ranges from 0 to 1. 2. data here is entire data and I created a mean column. Ideally I wanted to calculate it in <a href="https://seaborn.pydata.org/" rel="nofollow noreferrer">seaborn</a> plot rather than creating a mean column separately before.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-01T09:51:41.940Z
Comments.Text: I presume you import `seaborn` as `sns`, right?
Comments.UserDisplayName: Kamil S Jaron
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-01T10:37:51.967Z
Comments.Text: @KamilSJaron Yes
Comments.UserDisplayName: Megha
Tags: <python><visualization>
Title: How To display bar graph with error bars?
ThreadText: # How To display bar graph with error bars?
  
  (Asked by: username_0 on 2022-07-30)
  
  I am using the below code to get the bar plot. I want to get the bar plot with error bars displayed.
  
  ```
  import seaborn as sns
  
  def plot_coefficients(target, coeffs_df, n=10):
      if coeffs_df.shape[0]==0:
          return None # nothing to plot here!
      data = coeffs_df.copy()
      data = data.sort_values(('Coefficient','mean'), ascending=False).head(n)
      g = sns.barplot(
          data=data,
          y='Gene',
          x=('Coefficient','mean'),
          hue='Feature Type',
          hue_order=[
              h for h in [
                  'Genomic Variant',
                  'Gene Expression',
                  'Proteomics',
                  'Methylation',
              ] 
          ],
          dodge=False
      )
      g.set(
          xlim=(0,1),
          xlabel='Importance [0,1]',
          ylabel='',
          title=f"Top {target} predictor features"
      )
      return g
  
  ```
  
  Coefficient here is a score generated from predictive modelling that ranges from 0 to 1. 2. data here is entire data and I created a mean column. Ideally I wanted to calculate it in [seaborn](https://seaborn.pydata.org/) plot rather than creating a mean column separately before.
  
  **Tags:** python, visualization
  
  > **Comments:**
  > **username_1**: I presume you import `seaborn` as `sns`, right?  
  > **username_0**: @username_1 Yes  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2022-08-01. Score: 1
  
  I did put forward a comment, it was removed I think the idea is its a full post or zero. The problem proving a negative is tricky.
  
  I don't think its doable within the exact system specified, i.e. a Seaborn bar chart. Again I could be wrong.
  
  If the OP went to a Seaborn dot line formation - that would work `sns.barplot` is changed to `sns.pointplot` but then all the nice colouring disappears. Standard deviation is one error range if all the values are present: but I think the OP will need to request it (`.sd()` ?? can't remember).
  
  In `matplotlib` there is an error bar method where the coder specifies the error bars and that is `plt.errorbar`. An example from the official docs is [here](https://matplotlib.org/stable/gallery/lines_bars_and_markers/errorbar_limits_simple.html#sphx-glr-gallery-lines-bars-and-markers-errorbar-limits-simple-py). Thus call a bar chart and then add the error bars onto it.
  
  **Summary** The reasons I don't think its doable in Seaborn:
  
  1. I'm pretty certain Seaborn has no independent errorbar method unlike matplotlib
  2. Seaborn can do error bars given the full data set, but those are created automatically for a given method. Maybe there is a "sns.barplot-errorbar" method but I don't know it.
  
  The Seaborn approach does carry the advantage of not having to work out the error bar independently.
  
  
  ---
  
  