Top and bottom line on errorbar with python and seaborn

Anthony Lethuillier

I am trying to plot errorbars with python and seaborn but I am not entirely satisfied with how they look.

The default seaborn error bars look like this :

errobar default style

But I am looking to add the bottom and top lines on the error bars like this (in order to differentiated between the two error bars, it's the default matplotlib style) :

defaultmatplolib

How can I do this in seaborn ?

Here is the code:

import matplotlib.pyplot as plt
import seaborn as sns

fig1 = plt.figure(figsize=(20, 12))


x_values = [1,2,3,4]
y_values = [1,2,3,4]

y_error = [1,0.5,0.75,0.25]

plt.errorbar(x_values, y_values,  yerr=y_error ,fmt='o', markersize=8)

plt.show()
Tony Babarino

The capsize parameter should be enough, but for some reason You have to specify the cap.set_markeredgewidth for them to show up too.. Based on: Matplotlib Errorbar Caps Missing.

(_, caps, _) = plt.errorbar(
    x_values, y_values, yerr=y_error, fmt='o', markersize=8, capsize=20)

for cap in caps:
    cap.set_markeredgewidth(1)

returns:

enter image description here

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Python here document without newlines at top and bottom

Matplotlib errorbar extra space at top and bottom

How to make top line shorter than bottom line (within div)

Keep stdin line at top or bottom of terminal screen

Python Seaborn Matplotlib setting line style as legend

Line style of errorbar caps

ChartJS Line chart cut off at the top and bottom

White space on top and bottom Python matplotlib plot

How to moving top line to the bottom of the text in css

byobu: how to change status-line location from 'bottom' to 'top'?

Seaborn heatmap top and bottom row are partially truncated

How can I draw the right and top axis and remove the left and bottom axis in a Pairplot of Seaborn?

Round the top and bottom of dashed line drawn with UIBezierPath

How to put current line at top/center/bottom of screen in vim?

My divs line up from bottom to top instead of from top to bottom

Draw triangle at bottom or top of line

UIButton Top and Bottom Border additional line

Searching from Bottom to Top in Python

Android - toolbar at bottom - how to show a border line at the top

How to show a line moving from top to bottom like in a scanning process?

I need to line the bars up at the bottom, not the top

Heatmap of correlation matrix using seaborn not displaying properly at the top and bottom row

Is there a way to add a line plot on top of all plots within a Catplot grid in Seaborn/Python?

Flipping the contents of a file from bottom to top except for the first line

Markers on seaborn line plot in python

How to remove whitespace on top and bottom of seaborn scatterplots

How to read 2d array file from bottom-left to top line by line using Python

Material UI - Stepper top and bottom labels with line

Toolbar placed as bottom bar does not show line similar to top bar