Боке Горизонтальная диаграмма с накоплением - PullRequest
0 голосов
/ 18 мая 2018

Я пытаюсь преобразовать мою вертикальную гистограмму в горизонтальную гистограмму, но вращение не происходит.Я попытался использовать 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)

1 Ответ

0 голосов
/ 19 мая 2018

bokeh.charts, по-видимому, устарела в 0.12.9, поэтому я сделал это с последней версией (0.12.16 на момент написания), надеюсь, вы находитесь в состоянии, где вы можете обновить без проблем, должно бытьобратно совместимы довольно далеко назад.

Также я надеюсь, что стек верный путь! Этот пример также может помочь.

from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.io import show, output_file

# create data
products = ['python', 'pypy', 'jython']
customers = ['Cust 1', 'Cust 2']
colours = ['red', 'blue']
data = {
    'products': products,
    'Cust 1': [200, 850, 400],
    'Cust 2': [600, 620, 550]
}


source = ColumnDataSource(data)

p = figure(y_range=products)

p.hbar_stack(customers, y='products', height=0.5, source=source, color=colours)

show(p)
output_file("stacked.html")
...