{
 "metadata": {
  "name": "",
  "signature": "sha256:1924a880ed401c61f68c8705045514578011bcdeb5fdfcd256da113cb29afa79"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import bokeh\n",
      "bokeh.load_notebook()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from collections import OrderedDict\n",
      "\n",
      "import numpy as np\n",
      "\n",
      "from bokeh.charts import BoxPlot\n",
      "from bokeh.sampledata.olympics2014 import data\n",
      "\n",
      "data = {d['abbr']: d['medals'] for d in data['data'] if d['medals']['total'] > 0}\n",
      "\n",
      "countries = sorted(data.keys(), key=lambda x: data[x]['total'], reverse=True)\n",
      "\n",
      "gold = np.array([data[abbr]['gold'] for abbr in countries], dtype=np.float)\n",
      "silver = np.array([data[abbr]['silver'] for abbr in countries], dtype=np.float)\n",
      "bronze = np.array([data[abbr]['bronze'] for abbr in countries], dtype=np.float)\n",
      "\n",
      "medals = OrderedDict(bronze=bronze, silver=silver, gold=gold, fake=gold)\n",
      "\n",
      "boxplot = BoxPlot(medals, title=\"boxplot, dict_input\", xlabel=\"medal type\", ylabel=\"medal count\", \n",
      "             width=800, height=600, notebook=True)\n",
      "boxplot.marker(\"circle\").outliers(True).legend(True).show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "boxplot = BoxPlot(medals, title=\"boxplot, dict_input\", xlabel=\"medal type\", ylabel=\"medal count\", \n",
      "             width=800, height=600, notebook=True)\n",
      "boxplot.marker(\"circle\").outliers(False).legend(True).show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}