In [ ]:
import bokeh
bokeh.load_notebook()
In [ ]:
from collections import OrderedDict
import numpy as np
from bokeh.charts import BoxPlot
from bokeh.sampledata.olympics2014 import data
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)
boxplot = BoxPlot(medals, title="boxplot, dict_input", xlabel="medal type", ylabel="medal count",
width=800, height=600, notebook=True, marker="circle", outliers=True)
boxplot.show()
In [ ]:
from bokeh.plotting import output_notebook, show
boxplot = BoxPlot(medals, title="boxplot, dict_input", xlabel="medal type", ylabel="medal count",
width=800, height=600, notebook=True, marker="circle", outliers=False)
output_notebook()
show(boxplot)
In [ ]: