我试图将垂直堆积条形图转换为水平堆积条形图,但无法进行旋转。我尝试使用hbar来创建循环,但是图表最终还是保持不变。感谢所有提示!在
from bokeh.charts import Bar, output_file, show, hplot
from bokeh.models import HoverTool, ColumnDataSource, Range1d, LabelSet, Label
# create data
data = {
'customer': ['Cust 1', 'Cust 2', 'Cust 1', 'Cust 3', 'Cust 1', 'Cust 2'],
'itemSold': ['python', 'python', 'pypy', 'pypy', 'jython', 'jython'],
'sales': [200, 600, 850, 620, 400, 550]
}
#create hover tooltip
hover = HoverTool(tooltips=[
("sales", "$sales"),
("customer", "@customer"),
("itemSold", "@itemSold")
])
# x-axis itemSold , stacking customer
bar = Bar(data, values='sales', label='itemSold', stack='customer',
title="Python itemSold Sampling", legend='top_right', sizing_mode = "scale_both", tools=[hover, 'wheel_zoom'])
bar.hbar(y = data['sales'], height=0.5, right = data['customer'])
output_file("stacked.html")
show(bar)
在博克图表似乎在0.12.9中已经被弃用了,所以我已经用最新的版本(截至本文撰写时是0.12.16),希望您能够在没有任何问题的情况下进行升级,但是应该是向后兼容的。在
我也希望这堆东西是正确的!This example may also help.
相关问题 更多 >
编程相关推荐