{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from bokeh.sampledata import us_counties, unemployment\n",
      "from bokeh.plotting import *"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "county_xs=[\n",
      "    us_counties.data[code]['lons'] for code in us_counties.data\n",
      "    if us_counties.data[code]['state'] == 'tx'\n",
      "]\n",
      "county_ys=[\n",
      "    us_counties.data[code]['lats'] for code in us_counties.data\n",
      "    if us_counties.data[code]['state'] == 'tx'\n",
      "]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "colors = [\"#F1EEF6\", \"#D4B9DA\", \"#C994C7\", \"#DF65B0\", \"#DD1C77\", \"#980043\"]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "county_colors = []\n",
      "for county_id in us_counties.data:\n",
      "    if us_counties.data[county_id]['state'] != 'tx':\n",
      "        continue\n",
      "    try:\n",
      "        rate = unemployment.data[county_id]\n",
      "        idx = min(int(rate/2), 5)\n",
      "        county_colors.append(colors[idx])\n",
      "    except KeyError:\n",
      "        county_colors.append(\"black\")\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "output_notebook()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "patches(county_xs, county_ys, fill_color=county_colors, fill_alpha=0.7,\n",
      "        line_color=\"white\", line_width=0.5, title=\"Texas Unemployment 2009\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "show()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}