Reputation: 778
I am trying to draw a figure like that http://seaborn.pydata.org/_images/seaborn-barplot-1.png
As I understand bokeh don't have special method for barplot with error, so I decided to use Seaborn and then convert it into bokeh chart by to_bokeh() function.
sns.set_style("whitegrid")
plot = sns.barplot(data=[[1,2], [3,4]])
plot.get_figure().savefig('1.jpg')
l = layout([[widgetbox(*controls), to_bokeh(plot.get_figure())]])
save(l)
It save normal plot, like at the picture, but bokeh shows only error line, and no bars. What do I wrong, is it bug? Is there simpler way to draw chars like that in bokeh. I also should use strings as a ticks.Does bokeh support it?
Upvotes: 1
Views: 89
Reputation: 778
I have found solution (at least I hope :) )
box_plot = figure(x_range=['Ctrl', '- FBC', 'Rescue'])
X = range(1, 4)
Y = some_data # e.g. mean(data)
Err = another_piece_of_data # e.g. std(data)
box_plot.vbar(x=X, width=0.5, top=Y)
#add errors
err_xs = []
err_ys = []
for x, y, err in zip(X, Y, Err):
err_xs.append((x, x))
err_ys.append((y - err, y + err))
box_plot.multi_line(err_xs, err_ys, color='red', line_width=2)
l = layout([[box_plot]])
save(l)
Upvotes: 1