Remove tips/end bars from hv.ErrorBars?

Is there a parameter that controls/removes the tips/end bars from ErrorBars?

errors = [(0.1*i, np.sin(0.1*i), np.random.rand()/2, np.random.rand()/4) for i in np.linspace(0, 100, 11)]
hv.Curve(errors) * hv.ErrorBars(errors, vdims=['y', 'yerrneg', 'yerrpos'])

bokeh_plot

The options are upper_head and lower_head:

errors = [(0.1*i, np.sin(0.1*i), np.random.rand()/2, np.random.rand()/4) for i in np.linspace(0, 100, 11)]
hv.Curve(errors) * hv.ErrorBars(errors, vdims=['y', 'yerrneg', 'yerrpos']).opts(upper_head=None, lower_head=None)

you can also use hv.Path to draw the lines.
See holoviews_functions/StatisticalPlots.ipynb at master · ea42gh/holoviews_functions · GitHub
the function vertical_lines()

Thank you both for the solutions!

ErrorBars felt slightly counter-intuitive to me on first encounter – the errors are absolute deviations from the center, and not coordinate themselves like the center points. Although arguments probably can be made the other way round…

How can I change the color of the upper/lower heads?
In bokeh its done via upper_head.line_color: python - Bokeh whisker head color - Stack Overflow
Can I access such nested properties in HoloViews?

I don’t think there is a “clean” way to do this, but it can be done with hooks!

import holoviews as hv
import numpy as np
hv.extension("bokeh")

def hook(plot, element):
    plot.handles["glyph"].upper_head.line_color = "red"
    plot.handles["glyph"].lower_head.line_color = "green"

errors = [(0.1*i, np.sin(0.1*i), np.random.rand()/2, np.random.rand()/4) for i in np.linspace(0, 100, 11)]
hv.Curve(errors) * hv.ErrorBars(errors, vdims=['y', 'yerrneg', 'yerrpos']).opts(hooks=[hook])

image

1 Like