{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from collections import OrderedDict\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "from bokeh.charts import Step, output_notebook, show\n",
    "output_notebook()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# create some example data\n",
    "xyvalues = OrderedDict(\n",
    "    python=[2, 3, 7, 5, 26, 81, 44, 93, 94, 105, 66, 67, 90, 83],\n",
    "    pypy=[12, 20, 47, 15, 126, 121, 144, 333, 354, 225, 276, 287, 270, 230],\n",
    "    jython=[22, 43, 70, 75, 76, 101, 114, 123, 194, 215, 201, 227, 139, 160],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "step = Step(\n",
    "    xyvalues, title=\"Step Chart, dict input\", \n",
    "    legend='top_left', ylabel='Performance')\n",
    "show(step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "df = pd.DataFrame(xyvalues)\n",
    "step = Step(\n",
    "    df, title=\"Step Chart, pandas input\",legend='top_left',\n",
    "    ylabel='Performance')\n",
    "show(step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "step = Step(\n",
    "    list(xyvalues.values()), title=\"Step Chart, list input\", \n",
    "    legend='top_left', ylabel='Performance')\n",
    "show(step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# read in some stock data from the Yahoo Finance API\n",
    "AAPL = pd.read_csv(\n",
    "    \"http://ichart.yahoo.com/table.csv?s=AAPL&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n",
    "    parse_dates=['Date'])\n",
    "MSFT = pd.read_csv(\n",
    "    \"http://ichart.yahoo.com/table.csv?s=MSFT&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n",
    "    parse_dates=['Date'])\n",
    "IBM = pd.read_csv(\n",
    "    \"http://ichart.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2000&d=0&e=1&f=2010\",\n",
    "    parse_dates=['Date'])\n",
    "\n",
    "sxyvalues = OrderedDict(\n",
    "    AAPL=AAPL['Adj Close'],\n",
    "    MSFT=MSFT['Adj Close'],\n",
    "    IBM=IBM['Adj Close'],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "step = Step(\n",
    "    sxyvalues, title=\"Stock Prices\", \n",
    "    legend='top_left', ylabel='Price')\n",
    "show(step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from blaze import Data\n",
    "\n",
    "b = Data(df)\n",
    "step = Step(b, title=\"Step Chart (blaze)\", legend='top_left', ylabel='Performance')\n",
    "show(step)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
