In [ ]:
from collections import OrderedDict
import numpy as np
from bokeh.charts import BoxPlot, output_notebook, show
from bokeh.sampledata.olympics2014 import data
output_notebook()
In [ ]:
data = {d['abbr']: d['medals'] for d in 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)
medals = OrderedDict(bronze=bronze, silver=silver, gold=gold, fake=gold)
In [ ]:
boxplot = BoxPlot(
medals, title="boxplot, dict input", xlabel="medal type", ylabel="medal count",
width=600, height=400, marker="circle", outliers=True)
show(boxplot)
In [ ]:
from blaze import Data
from pandas import DataFrame
bmedals = Data(DataFrame(medals))
boxplot = BoxPlot(bmedals, title="boxplot, blaze input", xlabel="medal type", ylabel="medal count",
width=800, height=600, notebook=True, marker="circle", outliers=True)
show(boxplot)
In [ ]: