Skip to content

Instantly share code, notes, and snippets.

@RutgerK
Created October 26, 2016 12:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RutgerK/a13e996c9b8ddaf1fa3a02bd77a713a8 to your computer and use it in GitHub Desktop.
Save RutgerK/a13e996c9b8ddaf1fa3a02bd77a713a8 to your computer and use it in GitHub Desktop.
Custom heatmap
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" <div class=\"bk-root\">\n",
" <a href=\"http://bokeh.pydata.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
" <span id=\"28652abf-0556-48ef-9c47-482f3166b87d\">Loading BokehJS ...</span>\n",
" </div>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/javascript": [
"\n",
"(function(global) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
"\n",
" var force = \"1\";\n",
"\n",
" if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force !== \"\") {\n",
" window._bokeh_onload_callbacks = [];\n",
" window._bokeh_is_loading = undefined;\n",
" }\n",
"\n",
"\n",
" \n",
" if (typeof (window._bokeh_timeout) === \"undefined\" || force !== \"\") {\n",
" window._bokeh_timeout = Date.now() + 5000;\n",
" window._bokeh_failed_load = false;\n",
" }\n",
"\n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
"\n",
" function display_loaded() {\n",
" if (window.Bokeh !== undefined) {\n",
" Bokeh.$(\"#28652abf-0556-48ef-9c47-482f3166b87d\").text(\"BokehJS successfully loaded.\");\n",
" } else if (Date.now() < window._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
"\n",
" function run_callbacks() {\n",
" window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
" delete window._bokeh_onload_callbacks\n",
" console.info(\"Bokeh: all callbacks have finished\");\n",
" }\n",
"\n",
" function load_libs(js_urls, callback) {\n",
" window._bokeh_onload_callbacks.push(callback);\n",
" if (window._bokeh_is_loading > 0) {\n",
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" window._bokeh_is_loading = js_urls.length;\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = false;\n",
" s.onreadystatechange = s.onload = function() {\n",
" window._bokeh_is_loading--;\n",
" if (window._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
" run_callbacks()\n",
" }\n",
" };\n",
" s.onerror = function() {\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" }\n",
" };var element = document.getElementById(\"28652abf-0556-48ef-9c47-482f3166b87d\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '28652abf-0556-48ef-9c47-482f3166b87d' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
"\n",
" var js_urls = ['https://cdn.pydata.org/bokeh/release/bokeh-0.12.3.min.js', 'https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.3.min.js'];\n",
"\n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.set_log_level(\"info\");\n",
" },\n",
" \n",
" function(Bokeh) {\n",
" \n",
" Bokeh.$(\"#28652abf-0556-48ef-9c47-482f3166b87d\").text(\"BokehJS is loading...\");\n",
" },\n",
" function(Bokeh) {\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.3.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.12.3.min.css\");\n",
" console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.3.min.css\");\n",
" Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.3.min.css\");\n",
" }\n",
" ];\n",
"\n",
" function run_inline_js() {\n",
" \n",
" if ((window.Bokeh !== undefined) || (force === \"1\")) {\n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i](window.Bokeh);\n",
" }if (force === \"1\") {\n",
" display_loaded();\n",
" }} else if (Date.now() < window._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!window._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" window._bokeh_failed_load = true;\n",
" } else if (!force) {\n",
" var cell = $(\"#28652abf-0556-48ef-9c47-482f3166b87d\").parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
"\n",
" }\n",
"\n",
" if (window._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(js_urls, function() {\n",
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
"}(this));"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import datetime\n",
"\n",
"from bokeh.io import output_notebook, show\n",
"from bokeh.plotting import figure\n",
"from bokeh.models import ColumnDataSource, LinearColorMapper, DatetimeTickFormatter\n",
"from bokeh.palettes import Blues9, Greens9, Reds9\n",
"\n",
"output_notebook()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Create some dummy data"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>p1</th>\n",
" <th>p2</th>\n",
" <th>p3</th>\n",
" <th>start</th>\n",
" <th>end</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2016-01-01</th>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>7</td>\n",
" <td>2016-01-01</td>\n",
" <td>2016-01-02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-01-02</th>\n",
" <td>5</td>\n",
" <td>6</td>\n",
" <td>4</td>\n",
" <td>2016-01-02</td>\n",
" <td>2016-01-03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-01-03</th>\n",
" <td>6</td>\n",
" <td>8</td>\n",
" <td>6</td>\n",
" <td>2016-01-03</td>\n",
" <td>2016-01-04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-01-04</th>\n",
" <td>6</td>\n",
" <td>5</td>\n",
" <td>8</td>\n",
" <td>2016-01-04</td>\n",
" <td>2016-01-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2016-01-05</th>\n",
" <td>7</td>\n",
" <td>11</td>\n",
" <td>7</td>\n",
" <td>2016-01-05</td>\n",
" <td>2016-01-06</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" p1 p2 p3 start end\n",
"2016-01-01 7 7 7 2016-01-01 2016-01-02\n",
"2016-01-02 5 6 4 2016-01-02 2016-01-03\n",
"2016-01-03 6 8 6 2016-01-03 2016-01-04\n",
"2016-01-04 6 5 8 2016-01-04 2016-01-05\n",
"2016-01-05 7 11 7 2016-01-05 2016-01-06"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"start_dt = datetime.datetime(2016,1,1)\n",
"\n",
"params = ['p1', 'p2', 'p3']\n",
"\n",
"dfs = []\n",
"for p in params:\n",
" \n",
" dates = [start_dt + datetime.timedelta(minutes=int(x)) for x in np.random.randint(1,400,300).cumsum()] \n",
" dfs.append(pd.DataFrame({p: np.random.randn(len(dates))}, index=dates))\n",
" \n",
"df = pd.concat(dfs, axis=1)\n",
"\n",
"dfday = df.groupby(lambda x: x.date()).count()\n",
"\n",
"dfday['start'] = dfday.index\n",
"dfday['end'] = [x+datetime.timedelta(days=1) for x in dfday.index]\n",
"dfday.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Define colormaps for each param"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"cmaps = {}\n",
"cmaps['p1'] = LinearColorMapper(palette=Reds9)\n",
"cmaps['p2'] = LinearColorMapper(palette=Blues9)\n",
"cmaps['p3'] = LinearColorMapper(palette=Greens9)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Plot"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
" <div class=\"bk-root\">\n",
" <div class=\"plotdiv\" id=\"d7d1d690-109c-4862-b02a-d7a17060d7bc\"></div>\n",
" </div>\n",
"<script type=\"text/javascript\">\n",
" \n",
" (function(global) {\n",
" function now() {\n",
" return new Date();\n",
" }\n",
" \n",
" var force = \"\";\n",
" \n",
" if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force !== \"\") {\n",
" window._bokeh_onload_callbacks = [];\n",
" window._bokeh_is_loading = undefined;\n",
" }\n",
" \n",
" \n",
" \n",
" if (typeof (window._bokeh_timeout) === \"undefined\" || force !== \"\") {\n",
" window._bokeh_timeout = Date.now() + 0;\n",
" window._bokeh_failed_load = false;\n",
" }\n",
" \n",
" var NB_LOAD_WARNING = {'data': {'text/html':\n",
" \"<div style='background-color: #fdd'>\\n\"+\n",
" \"<p>\\n\"+\n",
" \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n",
" \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n",
" \"</p>\\n\"+\n",
" \"<ul>\\n\"+\n",
" \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n",
" \"<li>use INLINE resources instead, as so:</li>\\n\"+\n",
" \"</ul>\\n\"+\n",
" \"<code>\\n\"+\n",
" \"from bokeh.resources import INLINE\\n\"+\n",
" \"output_notebook(resources=INLINE)\\n\"+\n",
" \"</code>\\n\"+\n",
" \"</div>\"}};\n",
" \n",
" function display_loaded() {\n",
" if (window.Bokeh !== undefined) {\n",
" Bokeh.$(\"#d7d1d690-109c-4862-b02a-d7a17060d7bc\").text(\"BokehJS successfully loaded.\");\n",
" } else if (Date.now() < window._bokeh_timeout) {\n",
" setTimeout(display_loaded, 100)\n",
" }\n",
" }\n",
" \n",
" function run_callbacks() {\n",
" window._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n",
" delete window._bokeh_onload_callbacks\n",
" console.info(\"Bokeh: all callbacks have finished\");\n",
" }\n",
" \n",
" function load_libs(js_urls, callback) {\n",
" window._bokeh_onload_callbacks.push(callback);\n",
" if (window._bokeh_is_loading > 0) {\n",
" console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n",
" return null;\n",
" }\n",
" if (js_urls == null || js_urls.length === 0) {\n",
" run_callbacks();\n",
" return null;\n",
" }\n",
" console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n",
" window._bokeh_is_loading = js_urls.length;\n",
" for (var i = 0; i < js_urls.length; i++) {\n",
" var url = js_urls[i];\n",
" var s = document.createElement('script');\n",
" s.src = url;\n",
" s.async = false;\n",
" s.onreadystatechange = s.onload = function() {\n",
" window._bokeh_is_loading--;\n",
" if (window._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: all BokehJS libraries loaded\");\n",
" run_callbacks()\n",
" }\n",
" };\n",
" s.onerror = function() {\n",
" console.warn(\"failed to load library \" + url);\n",
" };\n",
" console.log(\"Bokeh: injecting script tag for BokehJS library: \", url);\n",
" document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
" }\n",
" };var element = document.getElementById(\"d7d1d690-109c-4862-b02a-d7a17060d7bc\");\n",
" if (element == null) {\n",
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'd7d1d690-109c-4862-b02a-d7a17060d7bc' but no matching script tag was found. \")\n",
" return false;\n",
" }\n",
" \n",
" var js_urls = [];\n",
" \n",
" var inline_js = [\n",
" function(Bokeh) {\n",
" Bokeh.$(function() {\n",
" var docs_json = {\"2f69f414-2596-428e-a9a2-5a5fa5187ef4\":{\"roots\":{\"references\":[{\"attributes\":{\"callback\":null,\"column_names\":[\"p3\",\"start\",\"p2\",\"end\",\"p1\",\"index\"],\"data\":{\"end\":[1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0,1455318000000.0],\"index\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0],\"p1\":[7,5,6,6,7,9,7,7,6,6,7,6,7,11,8,6,6,7,8,9,8,9,7,9,7,9,6,5,6,9,7,7,6,9,6,9,6,5,7,9,7,5,1],\"p2\":[7,6,8,5,11,8,6,5,6,6,9,7,7,8,7,6,8,6,9,7,6,8,8,8,7,6,8,5,7,7,8,8,6,6,7,5,8,9,9,7,9,6,0],\"p3\":[7,4,6,8,7,6,7,8,9,5,7,11,7,9,10,6,6,7,7,8,5,10,7,8,8,8,7,5,5,8,5,5,8,7,7,7,6,7,5,6,9,5,7],\"start\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0]}},\"id\":\"2cd594d9-b0f5-4c67-b3a8-015514507db1\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"base\":60,\"mantissas\":[1,2,5,10,15,20,30],\"max_interval\":1800000.0,\"min_interval\":1000.0,\"num_minor_ticks\":0},\"id\":\"e2e0d433-0be3-4b72-a37d-4251d837948f\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"days\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]},\"id\":\"3ff1bd62-ddee-4fc5-8db0-7f69d7f2f370\",\"type\":\"DaysTicker\"},{\"attributes\":{\"data_source\":{\"id\":\"2cd594d9-b0f5-4c67-b3a8-015514507db1\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"761f9623-26b5-4900-b45e-6f21fd5ba418\",\"type\":\"Quad\"},\"hover_glyph\":null,\"nonselection_glyph\":{\"id\":\"88a4c0c6-4f41-4e4b-aad2-90552b3ba754\",\"type\":\"Quad\"},\"selection_glyph\":null},\"id\":\"b350b1cf-ef5e-49d8-a538-2e8ae6f8c853\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"aeb7dac1-4e83-40c7-a4cf-f7c6e848efbc\",\"type\":\"BasicTicker\"},{\"attributes\":{\"months\":[0,4,8]},\"id\":\"be54cb78-e9a5-4668-811a-0f87f4e88ccb\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"months\":[0,6]},\"id\":\"224fa2cf-78fb-4b8e-9dd8-3d9850dfbda5\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"max_interval\":500.0,\"num_minor_ticks\":0},\"id\":\"8f5f4608-abff-44e1-a6ba-aec79df756de\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"p3\",\"start\",\"p2\",\"end\",\"p1\",\"index\"],\"data\":{\"end\":[1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0,1455318000000.0],\"index\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0],\"p1\":[7,5,6,6,7,9,7,7,6,6,7,6,7,11,8,6,6,7,8,9,8,9,7,9,7,9,6,5,6,9,7,7,6,9,6,9,6,5,7,9,7,5,1],\"p2\":[7,6,8,5,11,8,6,5,6,6,9,7,7,8,7,6,8,6,9,7,6,8,8,8,7,6,8,5,7,7,8,8,6,6,7,5,8,9,9,7,9,6,0],\"p3\":[7,4,6,8,7,6,7,8,9,5,7,11,7,9,10,6,6,7,7,8,5,10,7,8,8,8,7,5,5,8,5,5,8,7,7,7,6,7,5,6,9,5,7],\"start\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0]}},\"id\":\"ba140edc-b002-443a-8073-ef937d49e636\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"palette\":[\"#67000d\",\"#a50f15\",\"#cb181d\",\"#ef3b2c\",\"#fb6a4a\",\"#fc9272\",\"#fcbba1\",\"#fee0d2\",\"#fff5f0\"]},\"id\":\"7428a5f1-b5ae-4e05-aa20-43f2b643f108\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"bottom\":{\"value\":2.6},\"fill_color\":{\"field\":\"p3\",\"transform\":{\"id\":\"7047bbfd-e3be-4224-9d04-11b485b4d5e1\",\"type\":\"LinearColorMapper\"}},\"left\":{\"field\":\"start\"},\"line_color\":{\"field\":\"p3\",\"transform\":{\"id\":\"7047bbfd-e3be-4224-9d04-11b485b4d5e1\",\"type\":\"LinearColorMapper\"}},\"right\":{\"field\":\"end\"},\"top\":{\"value\":3.4}},\"id\":\"f298ba95-e734-4f94-8ac1-f0c17032eafe\",\"type\":\"Quad\"},{\"attributes\":{\"callback\":null,\"end\":4},\"id\":\"37098fc1-232c-4454-b685-9d65e75adaa4\",\"type\":\"Range1d\"},{\"attributes\":{\"data_source\":{\"id\":\"f1b12115-abe6-404a-b370-2ea230612d11\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"f2ac3127-c18d-468c-bb2e-59bbb0e7b5ec\",\"type\":\"Quad\"},\"hover_glyph\":null,\"nonselection_glyph\":{\"id\":\"b30fb1df-8055-4ce9-9265-8ac3b059d4e4\",\"type\":\"Quad\"},\"selection_glyph\":null},\"id\":\"2ef3513c-c672-4aa1-aa65-7de1c076bc03\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"dimensions\":\"width\",\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"9e4ae376-c05c-40cc-96ad-9c0574a4ae6c\",\"type\":\"PanTool\"},{\"attributes\":{\"bottom\":{\"value\":1.6},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"left\":{\"field\":\"start\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"right\":{\"field\":\"end\"},\"top\":{\"value\":2.4}},\"id\":\"b30fb1df-8055-4ce9-9265-8ac3b059d4e4\",\"type\":\"Quad\"},{\"attributes\":{\"palette\":[\"#08306b\",\"#08519c\",\"#2171b5\",\"#4292c6\",\"#6baed6\",\"#9ecae1\",\"#c6dbef\",\"#deebf7\",\"#f7fbff\"]},\"id\":\"59d73761-ff7d-4810-b9ab-dd776f541c1f\",\"type\":\"LinearColorMapper\"},{\"attributes\":{},\"id\":\"3cef3a6d-3707-494a-8686-aaa3082b6300\",\"type\":\"ToolEvents\"},{\"attributes\":{\"data_source\":{\"id\":\"ba140edc-b002-443a-8073-ef937d49e636\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"f298ba95-e734-4f94-8ac1-f0c17032eafe\",\"type\":\"Quad\"},\"hover_glyph\":null,\"nonselection_glyph\":{\"id\":\"8f5becc4-6230-44c7-b613-12be7ba80bcc\",\"type\":\"Quad\"},\"selection_glyph\":null},\"id\":\"6e05dd35-ed92-4081-8e1e-e881b914ccf7\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"days\":[1,4,7,10,13,16,19,22,25,28]},\"id\":\"01ed8505-fee9-44ea-ba25-a320c62f1a26\",\"type\":\"DaysTicker\"},{\"attributes\":{\"bottom\":{\"value\":2.6},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"left\":{\"field\":\"start\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"right\":{\"field\":\"end\"},\"top\":{\"value\":3.4}},\"id\":\"8f5becc4-6230-44c7-b613-12be7ba80bcc\",\"type\":\"Quad\"},{\"attributes\":{\"months\":[0,2,4,6,8,10]},\"id\":\"a4408b76-8a9d-40ad-857c-b82d68e3fa7e\",\"type\":\"MonthsTicker\"},{\"attributes\":{},\"id\":\"afe68675-4744-4da8-8765-b4d1d71ddadb\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"palette\":[\"#00441b\",\"#006d2c\",\"#238b45\",\"#41ab5d\",\"#74c476\",\"#a1d99b\",\"#c7e9c0\",\"#e5f5e0\",\"#f7fcf5\"]},\"id\":\"7047bbfd-e3be-4224-9d04-11b485b4d5e1\",\"type\":\"LinearColorMapper\"},{\"attributes\":{\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"d16bf94e-15ae-4592-9864-cd6c298d83b3\",\"type\":\"SaveTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"9e4ae376-c05c-40cc-96ad-9c0574a4ae6c\",\"type\":\"PanTool\"},{\"id\":\"4ff085ee-9caf-47ef-b846-5bf80310c40d\",\"type\":\"WheelZoomTool\"},{\"id\":\"a3ed8dd7-3478-4725-9d2c-52aaa85e9eab\",\"type\":\"ResetTool\"},{\"id\":\"d16bf94e-15ae-4592-9864-cd6c298d83b3\",\"type\":\"SaveTool\"},{\"id\":\"159e6478-8e70-4a00-b1be-6bdbafe211dc\",\"type\":\"ResizeTool\"}]},\"id\":\"32af394c-7360-4068-9021-9111f941b04d\",\"type\":\"Toolbar\"},{\"attributes\":{\"num_minor_ticks\":5},\"id\":\"297f63d3-0715-4121-a070-6b6573a7135d\",\"type\":\"DatetimeTicker\"},{\"attributes\":{\"formatter\":{\"id\":\"afe68675-4744-4da8-8765-b4d1d71ddadb\",\"type\":\"BasicTickFormatter\"},\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"aeb7dac1-4e83-40c7-a4cf-f7c6e848efbc\",\"type\":\"BasicTicker\"}},\"id\":\"479dcbdc-ff8e-4b93-8356-ff104e3916fe\",\"type\":\"LinearAxis\"},{\"attributes\":{\"bottom\":{\"value\":0.6},\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"left\":{\"field\":\"start\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"right\":{\"field\":\"end\"},\"top\":{\"value\":1.4}},\"id\":\"88a4c0c6-4f41-4e4b-aad2-90552b3ba754\",\"type\":\"Quad\"},{\"attributes\":{\"plot\":null,\"text\":null},\"id\":\"4a2d6ddc-8960-4855-b175-01c21d674aa3\",\"type\":\"Title\"},{\"attributes\":{\"callback\":null,\"column_names\":[\"p3\",\"start\",\"p2\",\"end\",\"p1\",\"index\"],\"data\":{\"end\":[1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0,1455318000000.0],\"index\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0],\"p1\":[7,5,6,6,7,9,7,7,6,6,7,6,7,11,8,6,6,7,8,9,8,9,7,9,7,9,6,5,6,9,7,7,6,9,6,9,6,5,7,9,7,5,1],\"p2\":[7,6,8,5,11,8,6,5,6,6,9,7,7,8,7,6,8,6,9,7,6,8,8,8,7,6,8,5,7,7,8,8,6,6,7,5,8,9,9,7,9,6,0],\"p3\":[7,4,6,8,7,6,7,8,9,5,7,11,7,9,10,6,6,7,7,8,5,10,7,8,8,8,7,5,5,8,5,5,8,7,7,7,6,7,5,6,9,5,7],\"start\":[1451602800000.0,1451689200000.0,1451775600000.0,1451862000000.0,1451948400000.0,1452034800000.0,1452121200000.0,1452207600000.0,1452294000000.0,1452380400000.0,1452466800000.0,1452553200000.0,1452639600000.0,1452726000000.0,1452812400000.0,1452898800000.0,1452985200000.0,1453071600000.0,1453158000000.0,1453244400000.0,1453330800000.0,1453417200000.0,1453503600000.0,1453590000000.0,1453676400000.0,1453762800000.0,1453849200000.0,1453935600000.0,1454022000000.0,1454108400000.0,1454194800000.0,1454281200000.0,1454367600000.0,1454454000000.0,1454540400000.0,1454626800000.0,1454713200000.0,1454799600000.0,1454886000000.0,1454972400000.0,1455058800000.0,1455145200000.0,1455231600000.0]}},\"id\":\"f1b12115-abe6-404a-b370-2ea230612d11\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"days\":[1,15]},\"id\":\"c8032a02-4b6f-4437-9a95-7ad2318a98ae\",\"type\":\"DaysTicker\"},{\"attributes\":{\"months\":[0,1,2,3,4,5,6,7,8,9,10,11]},\"id\":\"ab3365d3-7585-4cb8-9f7f-c9e5a8c9d5df\",\"type\":\"MonthsTicker\"},{\"attributes\":{\"base\":24,\"mantissas\":[1,2,4,6,8,12],\"max_interval\":43200000.0,\"min_interval\":3600000.0,\"num_minor_ticks\":0},\"id\":\"07ec32cf-25d7-4461-b15f-fe5f472ba19f\",\"type\":\"AdaptiveTicker\"},{\"attributes\":{\"below\":[{\"id\":\"ef2ab8b9-d8d9-41b2-90c6-00930ef5a217\",\"type\":\"DatetimeAxis\"}],\"left\":[{\"id\":\"479dcbdc-ff8e-4b93-8356-ff104e3916fe\",\"type\":\"LinearAxis\"}],\"plot_height\":300,\"plot_width\":800,\"renderers\":[{\"id\":\"ef2ab8b9-d8d9-41b2-90c6-00930ef5a217\",\"type\":\"DatetimeAxis\"},{\"id\":\"2853ff71-1444-488c-a4b0-f0ce83ee1594\",\"type\":\"Grid\"},{\"id\":\"479dcbdc-ff8e-4b93-8356-ff104e3916fe\",\"type\":\"LinearAxis\"},{\"id\":\"5d2b6f42-11bd-426c-aebf-795165f86a03\",\"type\":\"Grid\"},{\"id\":\"b350b1cf-ef5e-49d8-a538-2e8ae6f8c853\",\"type\":\"GlyphRenderer\"},{\"id\":\"2ef3513c-c672-4aa1-aa65-7de1c076bc03\",\"type\":\"GlyphRenderer\"},{\"id\":\"6e05dd35-ed92-4081-8e1e-e881b914ccf7\",\"type\":\"GlyphRenderer\"}],\"title\":{\"id\":\"4a2d6ddc-8960-4855-b175-01c21d674aa3\",\"type\":\"Title\"},\"tool_events\":{\"id\":\"3cef3a6d-3707-494a-8686-aaa3082b6300\",\"type\":\"ToolEvents\"},\"toolbar\":{\"id\":\"32af394c-7360-4068-9021-9111f941b04d\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"302aa39c-f1f6-4535-8cb1-e8aaa530fa7f\",\"type\":\"Range1d\"},\"y_range\":{\"id\":\"37098fc1-232c-4454-b685-9d65e75adaa4\",\"type\":\"Range1d\"}},\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"formatter\":{\"id\":\"c7a2b719-cf8e-47ba-8b1b-e753b7abfb67\",\"type\":\"DatetimeTickFormatter\"},\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"297f63d3-0715-4121-a070-6b6573a7135d\",\"type\":\"DatetimeTicker\"}},\"id\":\"ef2ab8b9-d8d9-41b2-90c6-00930ef5a217\",\"type\":\"DatetimeAxis\"},{\"attributes\":{\"dimensions\":\"width\",\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"4ff085ee-9caf-47ef-b846-5bf80310c40d\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"callback\":null,\"end\":1455231600000.0,\"start\":1451602800000.0},\"id\":\"302aa39c-f1f6-4535-8cb1-e8aaa530fa7f\",\"type\":\"Range1d\"},{\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"aeb7dac1-4e83-40c7-a4cf-f7c6e848efbc\",\"type\":\"BasicTicker\"}},\"id\":\"5d2b6f42-11bd-426c-aebf-795165f86a03\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"c4fac9d5-8753-4858-bc6a-1275902a4664\",\"type\":\"YearsTicker\"},{\"attributes\":{\"bottom\":{\"value\":0.6},\"fill_color\":{\"field\":\"p1\",\"transform\":{\"id\":\"7428a5f1-b5ae-4e05-aa20-43f2b643f108\",\"type\":\"LinearColorMapper\"}},\"left\":{\"field\":\"start\"},\"line_color\":{\"field\":\"p1\",\"transform\":{\"id\":\"7428a5f1-b5ae-4e05-aa20-43f2b643f108\",\"type\":\"LinearColorMapper\"}},\"right\":{\"field\":\"end\"},\"top\":{\"value\":1.4}},\"id\":\"761f9623-26b5-4900-b45e-6f21fd5ba418\",\"type\":\"Quad\"},{\"attributes\":{\"days\":[\"%d-%b-%Y\"]},\"id\":\"c7a2b719-cf8e-47ba-8b1b-e753b7abfb67\",\"type\":\"DatetimeTickFormatter\"},{\"attributes\":{\"bottom\":{\"value\":1.6},\"fill_color\":{\"field\":\"p2\",\"transform\":{\"id\":\"59d73761-ff7d-4810-b9ab-dd776f541c1f\",\"type\":\"LinearColorMapper\"}},\"left\":{\"field\":\"start\"},\"line_color\":{\"field\":\"p2\",\"transform\":{\"id\":\"59d73761-ff7d-4810-b9ab-dd776f541c1f\",\"type\":\"LinearColorMapper\"}},\"right\":{\"field\":\"end\"},\"top\":{\"value\":2.4}},\"id\":\"f2ac3127-c18d-468c-bb2e-59bbb0e7b5ec\",\"type\":\"Quad\"},{\"attributes\":{\"days\":[1,8,15,22]},\"id\":\"c8fd222d-1f67-4a2d-9833-e22a4da4741f\",\"type\":\"DaysTicker\"},{\"attributes\":{\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"},\"ticker\":{\"id\":\"297f63d3-0715-4121-a070-6b6573a7135d\",\"type\":\"DatetimeTicker\"}},\"id\":\"2853ff71-1444-488c-a4b0-f0ce83ee1594\",\"type\":\"Grid\"},{\"attributes\":{\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"a3ed8dd7-3478-4725-9d2c-52aaa85e9eab\",\"type\":\"ResetTool\"},{\"attributes\":{\"plot\":{\"id\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\",\"subtype\":\"Figure\",\"type\":\"Plot\"}},\"id\":\"159e6478-8e70-4a00-b1be-6bdbafe211dc\",\"type\":\"ResizeTool\"}],\"root_ids\":[\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\"]},\"title\":\"Bokeh Application\",\"version\":\"0.12.3\"}};\n",
" var render_items = [{\"docid\":\"2f69f414-2596-428e-a9a2-5a5fa5187ef4\",\"elementid\":\"d7d1d690-109c-4862-b02a-d7a17060d7bc\",\"modelid\":\"46e3ee55-ca31-4455-84c2-b4eb0b7e5bf9\"}];\n",
" \n",
" Bokeh.embed.embed_items(docs_json, render_items);\n",
" });\n",
" },\n",
" function(Bokeh) {\n",
" }\n",
" ];\n",
" \n",
" function run_inline_js() {\n",
" \n",
" if ((window.Bokeh !== undefined) || (force === \"1\")) {\n",
" for (var i = 0; i < inline_js.length; i++) {\n",
" inline_js[i](window.Bokeh);\n",
" }if (force === \"1\") {\n",
" display_loaded();\n",
" }} else if (Date.now() < window._bokeh_timeout) {\n",
" setTimeout(run_inline_js, 100);\n",
" } else if (!window._bokeh_failed_load) {\n",
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" window._bokeh_failed_load = true;\n",
" } else if (!force) {\n",
" var cell = $(\"#d7d1d690-109c-4862-b02a-d7a17060d7bc\").parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n",
" \n",
" }\n",
" \n",
" if (window._bokeh_is_loading === 0) {\n",
" console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
" run_inline_js();\n",
" } else {\n",
" load_libs(js_urls, function() {\n",
" console.log(\"Bokeh: BokehJS plotting callback run at\", now());\n",
" run_inline_js();\n",
" });\n",
" }\n",
" }(this));\n",
"</script>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"p = figure(x_axis_type=\"datetime\", x_range=(dfday.index[0], dfday.index[-1]), y_range=[0,4],\n",
" tools='xpan, xwheel_zoom, reset, save, resize', width=800, height=300)\n",
"\n",
"for i, par in enumerate(params):\n",
" \n",
" p.quad(left='start', right='end', bottom=.6+i, top=1.4+i,\n",
" color={'field': par, 'transform': cmaps[par]}, source=ColumnDataSource(dfday))\n",
"\n",
"p.xaxis.formatter = DatetimeTickFormatter(days=['%d-%b-%Y'])\n",
" \n",
"show(p)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.5"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment