title: Seaborn/matplotlib scatter plot, add error bars specific color
body: <p>How can I add error bars to a scatterplot, and control the color of the error bar?</p>
  <p>For example, I have this dataframe:</p>
  <pre><code>import pandas as pd
  import matplotlib.pyplot as plt
  import matplotlib.ticker as ticker
  import seaborn as sns
  
  df = pd.DataFrame(
      {
          &quot;id&quot;: [1, 2, 3, 4],
          &quot;x_mid&quot;: [0.5, 0.6, 0.2, 0.1],
          &quot;x_low&quot;: [0.41, 0.55, 0.18, 0.02],
          &quot;x_high&quot;: [0.66, 0.62, 0.3, 0.4],
          &quot;x_col&quot;: [&quot;black&quot;, &quot;black&quot;, &quot;red&quot;, &quot;black&quot;],
          &quot;y_mid&quot;: [0.4, 0.45, 0.33, 0.12],
          &quot;y_low&quot;: [0.35, 0.42, 0.3, 0.1],
          &quot;y_high&quot;: [0.5, 0.5, 0.38, 0.22],
          &quot;y_col&quot;: [&quot;red&quot;, &quot;black&quot;, &quot;red&quot;, &quot;black&quot;],
      }
  )
  
  display(df)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ppo6u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ppo6u.png" alt="enter image description here" /></a></p>
  <p>And here is the scatterplot. I am using Seaborn here, but will also consider answers using Matplotlib directly.</p>
  <pre><code>fig, ax = plt.subplots(figsize=(4, 4))
  
  g=sns.scatterplot(
      ax=ax,
      data=df,
      x=&quot;x_mid&quot;,
      y=&quot;y_mid&quot;,
  )
  
  ax.plot([0, 0.8], [0, 0.8], color=&quot;black&quot;, linewidth=1)
  ax.set(xlim=(0, 0.8), ylim=(0, 0.8))
  ax.grid(b=True, which=&quot;major&quot;)
  ax.xaxis.set_major_locator(ticker.MultipleLocator(0.2))
  ax.yaxis.set_major_locator(ticker.MultipleLocator(0.2))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/5BKr6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5BKr6.png" alt="enter image description here" /></a></p>
  <p>The &quot;x_col&quot; and &quot;y_col&quot; fields are the color for the error bar. So for the first row entry, the x range is (0.41, 0.66) and I want that to be a black error bar; and the y range is (0.35, 0.5), and I want that to be a red error bar, as sketched below.</p>
  <p>How can I add error bars, based on the x_ and y_ range in the dataframe, and control the color of the error bars?</p>
  <p>Using Python 3.8.3, Matplotlib 3.2.1, Seaborn 0.11.1</p>
  <p><a href="https://i.stack.imgur.com/U5PD7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U5PD7.png" alt="enter image description here" /></a></p>