我想在同一幅图上画两张条形图。
一个人只会有积极的价值观,一个人只会有消极的价值观。
我要绿色的正片(x轴上方)和红色的负条(x轴下方)。
问题:
1.是否可以使用bokeh.charts接口中现有的高级栏方法来完成此操作?
如果不是,如何使用较低级别的接口创建条形图?(而不是更高级的bokeh.charts接口)
发布于 2015-07-23 15:53:58
编辑:下面的答案已经过时几年了。现在,各种条形图(堆叠、分组、颜色映射)变得更加简单和容易了。有关许多示例,请参阅用户指南的本节:
1. --我尝试使用高级条形图方法做多个条形图,但是我无法实现我想要的结果,所以我使用了绘图接口。
2.是你要找的吗?
from bokeh.plotting import figure, output_file, show
plot = figure(width=600, height=600, x_range=(0,50), y_range=(-10,10))
plot.quad(top=[10],bottom=[0],left=[1],right=[2], color='green', line_color='black', legend='positive')
plot.quad(top=[12],bottom=[0],left=[2],right=[3], color='green', line_color='black', legend='positive')
plot.quad(top=[1],bottom=[0],left=[3],right=[4], color='green', line_color='black', legend='positive')
plot.quad(top=[2],bottom=[0],left=[4],right=[5], color='green', line_color='black', legend='positive')
plot.quad(top=[3],bottom=[0],left=[5],right=[6], color='green', line_color='black', legend='positive')
plot.quad(top=[4],bottom=[0],left=[6],right=[7], color='green', line_color='black', legend='positive')
plot.quad(top=[-5],bottom=[0],left=[1],right=[2], color='red', line_color='black', legend='negative')
plot.quad(top=[-6],bottom=[0],left=[2],right=[3], color='red', line_color='black', legend='negative')
plot.quad(top=[-2],bottom=[0],left=[3],right=[4], color='red', line_color='black', legend='negative')
plot.quad(top=[-8],bottom=[0],left=[4],right=[5], color='red', line_color='black', legend='negative')
plot.quad(top=[-9],bottom=[0],left=[5],right=[6], color='red', line_color='black', legend='negative')
plot.quad(top=[-10],bottom=[0],left=[6],right=[7], color='red', line_color='black', legend='negative')
output_file('test.html')
show(plot)
发布于 2018-03-23 12:18:03
您可以使用两个vbar_stack
调用:
volume_figure.vbar_stack(["buys"], x='timestamp', width=1.0, color=[colors.turquoise], source=source)
volume_figure.vbar_stack(["sells"], x='timestamp', width=1.0, color=[colors.tomato], source=source)
一般来说,条形图在docs部分处理分类数据中有详细的描述。
https://stackoverflow.com/questions/31527185
复制