Last active
May 12, 2017 21:49
-
-
Save aiguofer/98a4d9b31803038f843881d03bc1794c to your computer and use it in GitHub Desktop.
Width Change Doesnt Work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2017-01-27T21:44:38.772864", | |
"start_time": "2017-01-27T21:44:37.995726" | |
}, | |
"extensions": { | |
"jupyter_dashboards": { | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"col": 0, | |
"height": 4, | |
"hidden": true, | |
"row": 4, | |
"width": 4 | |
}, | |
"report_default": { | |
"hidden": false | |
} | |
} | |
} | |
}, | |
"scrolled": true, | |
"urth": { | |
"dashboard": { | |
"hidden": true | |
} | |
} | |
}, | |
"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=\"1015\">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 = true;\n", | |
"\n", | |
" if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", | |
" window._bokeh_onload_callbacks = [];\n", | |
" window._bokeh_is_loading = undefined;\n", | |
" }\n", | |
"\n", | |
"\n", | |
" \n", | |
" if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\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", | |
" var el = document.getElementById(\"1015\");\n", | |
" el.textContent = \"BokehJS \" + Bokeh.version + \" 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(\"1015\");\n", | |
" if (element == null) {\n", | |
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1015' but no matching script tag was found. \")\n", | |
" return false;\n", | |
" }\n", | |
"\n", | |
" var js_urls = [\"bokehjs/build/js/bokeh.js\", \"bokehjs/build/js/bokeh-widgets.js\"];\n", | |
"\n", | |
" var inline_js = [\n", | |
" function(Bokeh) {\n", | |
" Bokeh.set_log_level(\"debug\");\n", | |
" },\n", | |
" \n", | |
" function(Bokeh) {\n", | |
" \n", | |
" },\n", | |
" \n", | |
" function(Bokeh) {\n", | |
" \n", | |
" document.getElementById(\"1015\").textContent = \"BokehJS is loading...\";\n", | |
" },\n", | |
" function(Bokeh) {\n", | |
" console.log(\"Bokeh: injecting CSS: bokehjs/build/css/bokeh.css\");\n", | |
" Bokeh.embed.inject_css(\"bokehjs/build/css/bokeh.css\");\n", | |
" console.log(\"Bokeh: injecting CSS: bokehjs/build/css/bokeh-widgets.css\");\n", | |
" Bokeh.embed.inject_css(\"bokehjs/build/css/bokeh-widgets.css\");\n", | |
" }\n", | |
" ];\n", | |
"\n", | |
" function run_inline_js() {\n", | |
" \n", | |
" if ((window.Bokeh !== undefined) || (force === true)) {\n", | |
" for (var i = 0; i < inline_js.length; i++) {\n", | |
" inline_js[i](window.Bokeh);\n", | |
" }if (force === true) {\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 !== true) {\n", | |
" var cell = $(document.getElementById(\"1015\")).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 pandas as pd\n", | |
"import numpy as np\n", | |
"\n", | |
"from bokeh.plotting import figure, show\n", | |
"from bokeh.io import output_notebook, push_notebook\n", | |
"from bokeh.layouts import layout\n", | |
"from bokeh.models import ColumnDataSource, CustomJS, DataRange1d, LinearAxis, Range1d, DateFormatter\n", | |
"from bokeh.models.widgets import DataTable, TableColumn\n", | |
"\n", | |
"from ipywidgets import interact\n", | |
"\n", | |
"output_notebook()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2017-01-27T21:44:38.836386", | |
"start_time": "2017-01-27T21:44:38.776933" | |
}, | |
"collapsed": true, | |
"extensions": { | |
"jupyter_dashboards": { | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"hidden": true | |
}, | |
"report_default": { | |
"hidden": false | |
} | |
} | |
} | |
}, | |
"urth": { | |
"dashboard": {} | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"ix = pd.date_range('2016-01-01', '2017-01-01', freq='d', name='date')\n", | |
"srs = pd.Series(np.random.randint(0, 300, size=len(ix)), index=ix, name='volume')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2017-01-27T21:44:39.003060", | |
"start_time": "2017-01-27T21:44:38.839259" | |
}, | |
"extensions": { | |
"jupyter_dashboards": { | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"col": 0, | |
"height": 14, | |
"hidden": false, | |
"row": 31, | |
"width": 6 | |
}, | |
"report_default": { | |
"hidden": false | |
} | |
} | |
} | |
}, | |
"urth": { | |
"dashboard": {} | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"def get_data(freq='MS'):\n", | |
" return pd.DataFrame(srs.groupby(pd.Grouper(freq=freq)).sum())\n", | |
"\n", | |
"source = ColumnDataSource(data=ColumnDataSource.from_df(get_data()))\n", | |
"source_s = ColumnDataSource(data=ColumnDataSource.from_df(get_data() * .1))\n", | |
"\n", | |
"def get_width(pct=.8):\n", | |
" mindate = min(source.data['date'])\n", | |
" maxdate = max(source.data['date'])\n", | |
" return pct * (maxdate-mindate) / 1000000 / len(source.data['date'])\n", | |
"\n", | |
"f = figure(plot_width=550, plot_height=400, x_axis_type=\"datetime\", y_range=Range1d(0, max(source.data['volume']), bounds='auto'))\n", | |
"f.x_range.bounds='auto'\n", | |
"\n", | |
"r = f.vbar(source=source, top='volume', x='date', width=get_width())\n", | |
"r2 = f.vbar(source=source_s, top='volume', x='date', width=get_width(), color='green')\n", | |
"\n", | |
"f.tools[2].dimensions = 'width'" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2017-01-27T21:44:39.322862", | |
"start_time": "2017-01-27T21:44:39.066104" | |
}, | |
"extensions": { | |
"jupyter_dashboards": { | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"col": 0, | |
"height": 29, | |
"hidden": false, | |
"row": 2, | |
"width": 12 | |
}, | |
"report_default": { | |
"hidden": false | |
} | |
} | |
} | |
}, | |
"urth": { | |
"dashboard": { | |
"layout": { | |
"col": 0, | |
"height": 29, | |
"row": 0, | |
"width": 7 | |
} | |
} | |
} | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/html": [ | |
"\n", | |
"\n", | |
" <div class=\"bk-root\">\n", | |
" <div class=\"bk-plotdiv\" id=\"1177\"></div>\n", | |
" </div>\n", | |
"<script type=\"text/javascript\">\n", | |
" \n", | |
" (function(global) {\n", | |
" function now() {\n", | |
" return new Date();\n", | |
" }\n", | |
" \n", | |
" var force = false;\n", | |
" \n", | |
" if (typeof (window._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", | |
" window._bokeh_onload_callbacks = [];\n", | |
" window._bokeh_is_loading = undefined;\n", | |
" }\n", | |
" \n", | |
" \n", | |
" \n", | |
" if (typeof (window._bokeh_timeout) === \"undefined\" || force === true) {\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", | |
" var el = document.getElementById(\"1177\");\n", | |
" el.textContent = \"BokehJS \" + Bokeh.version + \" successfully loaded.\";\n", | |
" } else if (Date.now() < window._bokeh_timeout) {\n", | |
" setTimeout(display_loaded, 100)\n", | |
" }\n", | |
" }if ((window.Jupyter !== undefined) && Jupyter.notebook.kernel) {\n", | |
" comm_manager = Jupyter.notebook.kernel.comm_manager\n", | |
" comm_manager.register_target(\"1103\", function () {});\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(\"1177\");\n", | |
" if (element == null) {\n", | |
" console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1177' 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", | |
" (function() {\n", | |
" var fn = function() {\n", | |
" var docs_json = {\n", | |
" \"1176\": {\n", | |
" \"roots\": {\n", | |
" \"references\": [\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"fill_alpha\": {\n", | |
" \"value\": 0.1\n", | |
" },\n", | |
" \"fill_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"line_alpha\": {\n", | |
" \"value\": 0.1\n", | |
" },\n", | |
" \"line_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"top\": {\n", | |
" \"field\": \"volume\"\n", | |
" },\n", | |
" \"width\": {\n", | |
" \"value\": 1945993846\n", | |
" },\n", | |
" \"x\": {\n", | |
" \"field\": \"date\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1065\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"fill_color\": {\n", | |
" \"value\": \"green\"\n", | |
" },\n", | |
" \"line_color\": {\n", | |
" \"value\": \"green\"\n", | |
" },\n", | |
" \"top\": {\n", | |
" \"field\": \"volume\"\n", | |
" },\n", | |
" \"width\": {\n", | |
" \"value\": 1945993846\n", | |
" },\n", | |
" \"x\": {\n", | |
" \"field\": \"date\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1064\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": null,\n", | |
" \"text\": \"\"\n", | |
" },\n", | |
" \"id\": \"1045\",\n", | |
" \"type\": \"Title\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"max_interval\": 500.0,\n", | |
" \"num_minor_ticks\": 0\n", | |
" },\n", | |
" \"id\": \"1050\",\n", | |
" \"type\": \"AdaptiveTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"base\": 60,\n", | |
" \"mantissas\": [\n", | |
" 1,\n", | |
" 2,\n", | |
" 5,\n", | |
" 10,\n", | |
" 15,\n", | |
" 20,\n", | |
" 30\n", | |
" ],\n", | |
" \"max_interval\": 1800000.0,\n", | |
" \"min_interval\": 1000.0,\n", | |
" \"num_minor_ticks\": 0\n", | |
" },\n", | |
" \"id\": \"1051\",\n", | |
" \"type\": \"AdaptiveTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"base\": 24,\n", | |
" \"mantissas\": [\n", | |
" 1,\n", | |
" 2,\n", | |
" 4,\n", | |
" 6,\n", | |
" 8,\n", | |
" 12\n", | |
" ],\n", | |
" \"max_interval\": 43200000.0,\n", | |
" \"min_interval\": 3600000.0,\n", | |
" \"num_minor_ticks\": 0\n", | |
" },\n", | |
" \"id\": \"1052\",\n", | |
" \"type\": \"AdaptiveTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"days\": [\n", | |
" 1,\n", | |
" 2,\n", | |
" 3,\n", | |
" 4,\n", | |
" 5,\n", | |
" 6,\n", | |
" 7,\n", | |
" 8,\n", | |
" 9,\n", | |
" 10,\n", | |
" 11,\n", | |
" 12,\n", | |
" 13,\n", | |
" 14,\n", | |
" 15,\n", | |
" 16,\n", | |
" 17,\n", | |
" 18,\n", | |
" 19,\n", | |
" 20,\n", | |
" 21,\n", | |
" 22,\n", | |
" 23,\n", | |
" 24,\n", | |
" 25,\n", | |
" 26,\n", | |
" 27,\n", | |
" 28,\n", | |
" 29,\n", | |
" 30,\n", | |
" 31\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1053\",\n", | |
" \"type\": \"DaysTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"days\": [\n", | |
" 1,\n", | |
" 4,\n", | |
" 7,\n", | |
" 10,\n", | |
" 13,\n", | |
" 16,\n", | |
" 19,\n", | |
" 22,\n", | |
" 25,\n", | |
" 28\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1054\",\n", | |
" \"type\": \"DaysTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"days\": [\n", | |
" 1,\n", | |
" 8,\n", | |
" 15,\n", | |
" 22\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1055\",\n", | |
" \"type\": \"DaysTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"days\": [\n", | |
" 1,\n", | |
" 15\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1056\",\n", | |
" \"type\": \"DaysTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"months\": [\n", | |
" 0,\n", | |
" 1,\n", | |
" 2,\n", | |
" 3,\n", | |
" 4,\n", | |
" 5,\n", | |
" 6,\n", | |
" 7,\n", | |
" 8,\n", | |
" 9,\n", | |
" 10,\n", | |
" 11\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1057\",\n", | |
" \"type\": \"MonthsTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"months\": [\n", | |
" 0,\n", | |
" 2,\n", | |
" 4,\n", | |
" 6,\n", | |
" 8,\n", | |
" 10\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1058\",\n", | |
" \"type\": \"MonthsTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"months\": [\n", | |
" 0,\n", | |
" 4,\n", | |
" 8\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1059\",\n", | |
" \"type\": \"MonthsTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1038\",\n", | |
" \"type\": \"HelpTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"bottom_units\": \"screen\",\n", | |
" \"fill_alpha\": {\n", | |
" \"value\": 0.5\n", | |
" },\n", | |
" \"fill_color\": {\n", | |
" \"value\": \"lightgrey\"\n", | |
" },\n", | |
" \"left_units\": \"screen\",\n", | |
" \"level\": \"overlay\",\n", | |
" \"line_alpha\": {\n", | |
" \"value\": 1.0\n", | |
" },\n", | |
" \"line_color\": {\n", | |
" \"value\": \"black\"\n", | |
" },\n", | |
" \"line_dash\": [\n", | |
" 4,\n", | |
" 4\n", | |
" ],\n", | |
" \"line_width\": {\n", | |
" \"value\": 2\n", | |
" },\n", | |
" \"plot\": null,\n", | |
" \"render_mode\": \"css\",\n", | |
" \"right_units\": \"screen\",\n", | |
" \"top_units\": \"screen\"\n", | |
" },\n", | |
" \"id\": \"1039\",\n", | |
" \"type\": \"BoxAnnotation\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"bounds\": \"auto\",\n", | |
" \"callback\": null,\n", | |
" \"end\": 5638\n", | |
" },\n", | |
" \"id\": \"1018\",\n", | |
" \"type\": \"Range1d\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {},\n", | |
" \"id\": \"1019\",\n", | |
" \"type\": \"ToolEvents\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"dimension\": 1,\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" },\n", | |
" \"ticker\": {\n", | |
" \"id\": \"1029\",\n", | |
" \"type\": \"BasicTicker\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1032\",\n", | |
" \"type\": \"Grid\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1033\",\n", | |
" \"type\": \"PanTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"callback\": null,\n", | |
" \"column_names\": [\n", | |
" \"volume\",\n", | |
" \"date\"\n", | |
" ],\n", | |
" \"data\": {\n", | |
" \"date\": {\n", | |
" \"__ndarray__\": \"AADAvacfdUIAAAAQoil1QgAAwJb3MnVCAAAA6fE8dUIAAIDVmUZ1QgAAwCeUUHVCAABAFDxadUIAAIBmNmR1QgAAwLgwbnVCAABApdh3dUIAAID30oF1QgAAAOR6i3VCAABANnWVdUI=\",\n", | |
" \"dtype\": \"float64\",\n", | |
" \"shape\": [\n", | |
" 13\n", | |
" ]\n", | |
" },\n", | |
" \"volume\": [\n", | |
" 5414,\n", | |
" 2911,\n", | |
" 5638,\n", | |
" 4155,\n", | |
" 4193,\n", | |
" 4614,\n", | |
" 4136,\n", | |
" 5077,\n", | |
" 3829,\n", | |
" 4141,\n", | |
" 4260,\n", | |
" 4731,\n", | |
" 251\n", | |
" ]\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1016\",\n", | |
" \"type\": \"ColumnDataSource\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"callback\": null,\n", | |
" \"column_names\": [\n", | |
" \"volume\",\n", | |
" \"date\"\n", | |
" ],\n", | |
" \"data\": {\n", | |
" \"date\": {\n", | |
" \"__ndarray__\": \"AADAvacfdUIAAAAQoil1QgAAwJb3MnVCAAAA6fE8dUIAAIDVmUZ1QgAAwCeUUHVCAABAFDxadUIAAIBmNmR1QgAAwLgwbnVCAABApdh3dUIAAID30oF1QgAAAOR6i3VCAABANnWVdUI=\",\n", | |
" \"dtype\": \"float64\",\n", | |
" \"shape\": [\n", | |
" 13\n", | |
" ]\n", | |
" },\n", | |
" \"volume\": {\n", | |
" \"__ndarray__\": \"MzMzMzPrgECamZmZmTFyQGdmZmZmnoFAAAAAAAD4eUDNzMzMzDR6QGdmZmZm1nxAmpmZmZnZeUA0MzMzM7t/QGdmZmZm7ndAmpmZmZnheUAAAAAAAKB6QJqZmZmZkX1AmpmZmZkZOUA=\",\n", | |
" \"dtype\": \"float64\",\n", | |
" \"shape\": [\n", | |
" 13\n", | |
" ]\n", | |
" }\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1017\",\n", | |
" \"type\": \"ColumnDataSource\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1036\",\n", | |
" \"type\": \"SaveTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1037\",\n", | |
" \"type\": \"ResetTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1034\",\n", | |
" \"type\": \"WheelZoomTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"dimensions\": \"width\",\n", | |
" \"overlay\": {\n", | |
" \"id\": \"1039\",\n", | |
" \"type\": \"BoxAnnotation\"\n", | |
" },\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1035\",\n", | |
" \"type\": \"BoxZoomTool\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"num_minor_ticks\": 5\n", | |
" },\n", | |
" \"id\": \"1024\",\n", | |
" \"type\": \"DatetimeTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"below\": [\n", | |
" {\n", | |
" \"id\": \"1023\",\n", | |
" \"type\": \"DatetimeAxis\"\n", | |
" }\n", | |
" ],\n", | |
" \"left\": [\n", | |
" {\n", | |
" \"id\": \"1028\",\n", | |
" \"type\": \"LinearAxis\"\n", | |
" }\n", | |
" ],\n", | |
" \"plot_height\": 400,\n", | |
" \"plot_width\": 550,\n", | |
" \"renderers\": [\n", | |
" {\n", | |
" \"id\": \"1023\",\n", | |
" \"type\": \"DatetimeAxis\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1027\",\n", | |
" \"type\": \"Grid\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1028\",\n", | |
" \"type\": \"LinearAxis\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1032\",\n", | |
" \"type\": \"Grid\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1039\",\n", | |
" \"type\": \"BoxAnnotation\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1044\",\n", | |
" \"type\": \"GlyphRenderer\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1066\",\n", | |
" \"type\": \"GlyphRenderer\"\n", | |
" }\n", | |
" ],\n", | |
" \"title\": {\n", | |
" \"id\": \"1045\",\n", | |
" \"type\": \"Title\"\n", | |
" },\n", | |
" \"tool_events\": {\n", | |
" \"id\": \"1019\",\n", | |
" \"type\": \"ToolEvents\"\n", | |
" },\n", | |
" \"toolbar\": {\n", | |
" \"id\": \"1020\",\n", | |
" \"type\": \"Toolbar\"\n", | |
" },\n", | |
" \"x_range\": {\n", | |
" \"id\": \"1022\",\n", | |
" \"type\": \"DataRange1d\"\n", | |
" },\n", | |
" \"y_range\": {\n", | |
" \"id\": \"1018\",\n", | |
" \"type\": \"Range1d\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"fill_alpha\": {\n", | |
" \"value\": 0.1\n", | |
" },\n", | |
" \"fill_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"line_alpha\": {\n", | |
" \"value\": 0.1\n", | |
" },\n", | |
" \"line_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"top\": {\n", | |
" \"field\": \"volume\"\n", | |
" },\n", | |
" \"width\": {\n", | |
" \"value\": 1945993846\n", | |
" },\n", | |
" \"x\": {\n", | |
" \"field\": \"date\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1043\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"fill_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"line_color\": {\n", | |
" \"value\": \"#1f77b4\"\n", | |
" },\n", | |
" \"top\": {\n", | |
" \"field\": \"volume\"\n", | |
" },\n", | |
" \"width\": {\n", | |
" \"value\": 1945993846\n", | |
" },\n", | |
" \"x\": {\n", | |
" \"field\": \"date\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1042\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" },\n", | |
" \"ticker\": {\n", | |
" \"id\": \"1024\",\n", | |
" \"type\": \"DatetimeTicker\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1027\",\n", | |
" \"type\": \"Grid\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {},\n", | |
" \"id\": \"1047\",\n", | |
" \"type\": \"DatetimeTickFormatter\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"active_drag\": \"auto\",\n", | |
" \"active_inspect\": \"auto\",\n", | |
" \"active_scroll\": \"auto\",\n", | |
" \"active_tap\": \"auto\",\n", | |
" \"tools\": [\n", | |
" {\n", | |
" \"id\": \"1033\",\n", | |
" \"type\": \"PanTool\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1034\",\n", | |
" \"type\": \"WheelZoomTool\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1035\",\n", | |
" \"type\": \"BoxZoomTool\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1036\",\n", | |
" \"type\": \"SaveTool\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1037\",\n", | |
" \"type\": \"ResetTool\"\n", | |
" },\n", | |
" {\n", | |
" \"id\": \"1038\",\n", | |
" \"type\": \"HelpTool\"\n", | |
" }\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1020\",\n", | |
" \"type\": \"Toolbar\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"formatter\": {\n", | |
" \"id\": \"1047\",\n", | |
" \"type\": \"DatetimeTickFormatter\"\n", | |
" },\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" },\n", | |
" \"ticker\": {\n", | |
" \"id\": \"1024\",\n", | |
" \"type\": \"DatetimeTicker\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1023\",\n", | |
" \"type\": \"DatetimeAxis\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"bounds\": \"auto\",\n", | |
" \"callback\": null\n", | |
" },\n", | |
" \"id\": \"1022\",\n", | |
" \"type\": \"DataRange1d\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {},\n", | |
" \"id\": \"1061\",\n", | |
" \"type\": \"YearsTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"months\": [\n", | |
" 0,\n", | |
" 6\n", | |
" ]\n", | |
" },\n", | |
" \"id\": \"1060\",\n", | |
" \"type\": \"MonthsTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {},\n", | |
" \"id\": \"1049\",\n", | |
" \"type\": \"BasicTickFormatter\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"data_source\": {\n", | |
" \"id\": \"1016\",\n", | |
" \"type\": \"ColumnDataSource\"\n", | |
" },\n", | |
" \"glyph\": {\n", | |
" \"id\": \"1042\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" \"hover_glyph\": null,\n", | |
" \"muted_glyph\": null,\n", | |
" \"nonselection_glyph\": {\n", | |
" \"id\": \"1043\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" \"selection_glyph\": null\n", | |
" },\n", | |
" \"id\": \"1044\",\n", | |
" \"type\": \"GlyphRenderer\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {},\n", | |
" \"id\": \"1029\",\n", | |
" \"type\": \"BasicTicker\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"formatter\": {\n", | |
" \"id\": \"1049\",\n", | |
" \"type\": \"BasicTickFormatter\"\n", | |
" },\n", | |
" \"plot\": {\n", | |
" \"id\": \"1021\",\n", | |
" \"subtype\": \"Figure\",\n", | |
" \"type\": \"Plot\"\n", | |
" },\n", | |
" \"ticker\": {\n", | |
" \"id\": \"1029\",\n", | |
" \"type\": \"BasicTicker\"\n", | |
" }\n", | |
" },\n", | |
" \"id\": \"1028\",\n", | |
" \"type\": \"LinearAxis\"\n", | |
" },\n", | |
" {\n", | |
" \"attributes\": {\n", | |
" \"data_source\": {\n", | |
" \"id\": \"1017\",\n", | |
" \"type\": \"ColumnDataSource\"\n", | |
" },\n", | |
" \"glyph\": {\n", | |
" \"id\": \"1064\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" \"hover_glyph\": null,\n", | |
" \"muted_glyph\": null,\n", | |
" \"nonselection_glyph\": {\n", | |
" \"id\": \"1065\",\n", | |
" \"type\": \"VBar\"\n", | |
" },\n", | |
" \"selection_glyph\": null\n", | |
" },\n", | |
" \"id\": \"1066\",\n", | |
" \"type\": \"GlyphRenderer\"\n", | |
" }\n", | |
" ],\n", | |
" \"root_ids\": [\n", | |
" \"1021\"\n", | |
" ]\n", | |
" },\n", | |
" \"title\": \"Bokeh Application\",\n", | |
" \"version\": \"0.12.5dev11-333-g602090079\"\n", | |
" }\n", | |
" };\n", | |
" var render_items = [\n", | |
" {\n", | |
" \"docid\": \"1176\",\n", | |
" \"elementid\": \"1177\",\n", | |
" \"modelid\": \"1021\",\n", | |
" \"notebook_comms_target\": \"1103\"\n", | |
" }\n", | |
" ];\n", | |
" \n", | |
" Bokeh.embed.embed_items(docs_json, render_items);\n", | |
" };\n", | |
" if (document.readyState != \"loading\") fn();\n", | |
" else document.addEventListener(\"DOMContentLoaded\", fn);\n", | |
" })();\n", | |
" },\n", | |
" function(Bokeh) {\n", | |
" }\n", | |
" ];\n", | |
" \n", | |
" function run_inline_js() {\n", | |
" \n", | |
" if ((window.Bokeh !== undefined) || (force === true)) {\n", | |
" for (var i = 0; i < inline_js.length; i++) {\n", | |
" inline_js[i](window.Bokeh);\n", | |
" }if (force === true) {\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 !== true) {\n", | |
" var cell = $(document.getElementById(\"1177\")).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": [ | |
"all_handle = show(f, notebook_handle=True)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"ExecuteTime": { | |
"end_time": "2017-01-27T21:44:39.405397", | |
"start_time": "2017-01-27T21:44:39.325434" | |
}, | |
"extensions": { | |
"jupyter_dashboards": { | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"col": 0, | |
"height": 2, | |
"hidden": false, | |
"row": 0, | |
"width": 12 | |
}, | |
"report_default": { | |
"hidden": false | |
} | |
} | |
} | |
}, | |
"urth": { | |
"dashboard": { | |
"layout": { | |
"col": 7, | |
"height": 26, | |
"row": 0, | |
"width": 4 | |
} | |
} | |
} | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Widget Javascript not detected. It may not be installed or enabled properly.\n" | |
] | |
}, | |
{ | |
"data": { | |
"application/vnd.jupyter.widget-view+json": { | |
"model_id": "897825aed2f144c2b10d526a5992f009" | |
} | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
} | |
], | |
"source": [ | |
"def update_data(w='1'):\n", | |
" w = float(w)\n", | |
" r.glyph.width = get_width(w)\n", | |
" r2.glyph.width = get_width(w)\n", | |
"\n", | |
" push_notebook(handle=all_handle)\n", | |
" \n", | |
"i = interact(update_data)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"collapsed": true, | |
"urth": { | |
"dashboard": { | |
"layout": { | |
"col": 7, | |
"height": 5, | |
"row": 26, | |
"width": 4 | |
} | |
} | |
} | |
}, | |
"outputs": [], | |
"source": [ | |
"update_data(w=.5)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 9, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"update_data(w=.1)" | |
] | |
} | |
], | |
"metadata": { | |
"extensions": { | |
"jupyter_dashboards": { | |
"activeView": "grid_default", | |
"version": 1, | |
"views": { | |
"grid_default": { | |
"cellMargin": 10, | |
"defaultCellHeight": 20, | |
"layoutStrategy": "packed", | |
"maxColumns": 12, | |
"name": "grid", | |
"type": "grid" | |
}, | |
"report_default": { | |
"name": "report", | |
"type": "report" | |
} | |
} | |
} | |
}, | |
"hide_input": false, | |
"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.13" | |
}, | |
"urth": { | |
"dashboard": { | |
"cellMargin": 10, | |
"defaultCellHeight": 20, | |
"layoutStrategy": "packed", | |
"maxColumns": 12 | |
} | |
}, | |
"widgets": { | |
"state": { | |
"6ecece1fc2054ab8aa46bb74f01d993a": { | |
"views": [ | |
{ | |
"cell_index": 4 | |
} | |
] | |
} | |
}, | |
"version": "1.2.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment