1 year ago

#242406

test-img

gioarma

How to add an errorbar to jittered scatter plot in holoviews/hvplot

I have a DataFrame like this:

biases = ['+5V']*3 + ['-5V']*8
df = pd.DataFrame({'Bias': biases, 
                   'Ea': [1.059, 0.287, 0.451, 0.533, 0.587, 0.466, 0.805, 0.499, 0.473, 0.721, 0.461],
                   'dEa': [0.072,0.005,0.004,0.018,0.036,0.032,0.009,0.015,0.011,0.044,0.004]})

print(df.head())

  Bias     Ea    dEa
3  -5V  0.533  0.018
4  -5V  0.587  0.036
5  -5V  0.466  0.032
6  -5V  0.805  0.009
7  -5V  0.499  0.015

I would like to make a scatterplot with Bias on the x axis, Ea on the y axis, the y errors should be given by dEa. I can do it easily with:

df.hvplot.scatter(x='Bias', y='Ea')*\
df.hvplot.errorbars(x='Bias', y='Ea', yerr1='dEa')

The problem is that I want to add a jitter to this plot, but only the hv.scatter function has the jitter option. Therefore, by calling df.hvplot.scatter(x='Bias', y='Ea').opts(jitter=0.1) I get the jitter only on the scatter plot and not on the errors:

enter image description here

Do you have any idea on how can I get the errors to follow the scatter points?

pandas

plot

bokeh

holoviews

hvplot

0 Answers

Your Answer

Accepted video resources