Errorbars#

import hvplot.pandas  # noqa

errorbars are most helpful when overlaid with other plot types. To do this we’ll use the * operator.

from bokeh.sampledata import perceptions

data = perceptions.numberly.describe().transpose().sort_values('mean')
data
count mean std min 25% 50% 75% max
A couple 46.0 2.326087 1.033964 2.00 2.0000 2.000 2.000 8.0
A few 46.0 3.608696 1.357747 2.00 3.0000 3.000 4.000 10.0
Some 46.0 4.739130 2.123255 2.00 3.2500 4.500 5.000 15.0
Fractions of 46.0 5.109783 16.847218 0.01 0.1625 0.365 0.875 100.0
Several 46.0 6.304348 2.096235 2.00 5.0000 7.000 7.750 10.0
Dozens 46.0 35.130435 17.119980 12.00 24.0000 36.000 36.000 120.0
Many 46.0 44.065217 145.464223 5.00 9.2500 20.000 25.000 1000.0
A lot 46.0 85.065217 431.917451 7.00 10.0000 14.500 22.250 2948.0
Hundreds of 46.0 400.804348 424.387015 100.00 212.5000 300.000 475.000 3000.0
Scores of 46.0 3017.456522 15266.869723 3.00 40.0000 80.000 200.000 100000.0

First we’ll use just one column to set the size of the errorbars around ‘mean’.

data.hvplot.scatter(y='mean', ylabel='amount') * data.hvplot.errorbars(y='mean', yerr1='std')

Then we’ll use two columns. Remember that these are not the absolute placements of the ends of the bars, but the distance from the center.

data['yerr1'] = data['mean'] - data['min']
data['yerr2'] = data['max'] - data['mean']
data.hvplot.scatter(y='mean', ylabel='amount') * data.hvplot.errorbars(y='mean', yerr1='yerr1', yerr2='yerr2')
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.