In [ ]:
from collections import OrderedDict
import numpy as np
import pandas as pd
from bokeh.charts import Bar, output_notebook, show
from bokeh.plotting import VBox
from bokeh.sampledata.olympics2014 import data as original_data

In [ ]:
data = {d['abbr']: d['medals'] for d in original_data['data'] if d['medals']['total'] > 0}

countries = sorted(data.keys(), key=lambda x: data[x]['total'], reverse=True)

gold = np.array([data[abbr]['gold'] for abbr in countries], dtype=np.float)
silver = np.array([data[abbr]['silver'] for abbr in countries], dtype=np.float)
bronze = np.array([data[abbr]['bronze'] for abbr in countries], dtype=np.float)
output_notebook()
medals = OrderedDict(bronze=bronze, silver=silver, gold=gold)

In [ ]:
bar = Bar(
    medals, countries, title="grouped, dict input", 
    xlabel="countries", ylabel="medals", legend="top_right", width=600, height=400)
show(bar)

In [ ]:
bar = Bar(
    medals, countries, title="stacked, dict input", 
    xlabel="countries", ylabel="medals", legend="top_right", width=600, height=400, stacked=True)
show(bar)

In [ ]:
df = pd.DataFrame(medals, index=countries)

bar1 = Bar(
    df, title="stacked, pandas input", xlabel="countries", ylabel="medals", 
    legend="top_right", width=600, height=400, stacked=True)

bar2 = bar = Bar(
    df, title="grouped, pandas input", xlabel="countries", ylabel="medals", 
    legend="top_right", width=600, height=400, stacked=False)

show(VBox(bar1, bar2))

In [ ]:
medals = np.array([bronze, silver, gold])
bar = Bar(
    medals, title="grouped, array input", xlabel="countries", ylabel="medals", 
    legend="top_right", width=600, height=400)
show(bar)

In [ ]:
from blaze import Data

medals = Data(df)
bar = Bar(
    medals, cat=countries, title="grouped, df_input", xlabel="countries", 
    ylabel="medals", legend='top_right', stacked=True, width=800, height=600)
show(bar)

In [ ]: