{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# NetworkX to Bokeh | Layout for Custom Node position" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:18.616800Z", "start_time": "2018-09-23T04:05:16.848556Z" } }, "outputs": [], "source": [ "import sys\n", "\n", "import matplotlib.pyplot as plt\n", "import networkx as nx\n", "import bokeh\n", "from bokeh.io import show, output_notebook\n", "from bokeh.models import Plot, Range1d, MultiLine, Circle, HoverTool, StaticLayoutProvider\n", "from bokeh.models.graphs import from_networkx\n", "\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:19.143398Z", "start_time": "2018-09-23T04:05:19.134082Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "NetworkX: 2.2\n", "Bokeh: 0.13.0\n", "Python: 3.6.2\n" ] } ], "source": [ "print('NetworkX: {}'.format(nx.__version__))\n", "print('Bokeh: {}'.format(bokeh.__version__))\n", "print('Python: {}.{}.{}'.format(sys.version_info.major, sys.version_info.minor, sys.version_info.micro))" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2018-09-23T03:05:52.273308Z", "start_time": "2018-09-23T03:05:52.269845Z" } }, "source": [ "## Prepare data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:20.540839Z", "start_time": "2018-09-23T04:05:20.177850Z" } }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4wLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvpW3flQAAIABJREFUeJzt3Xd4VGX+/vH3JyG00KRJkbp0pBoCKFItyLLMJIRQAqEjKCoKKsU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mzx0oGpUDLXQWII0eOEB0dTUJCAs2bN7eapW3btsyaNQuHw8HJkyetZlHBS8td+b3MzExiYmKIj4+nd+/etuMAMHToUO644w769+9PzgVuyK1UYdNyV35v3LhxlCtXjkcffdR2lD+YM2cO586dY8qUKbajqCCkE6rKry1evJh33nmHHTt2EBLiW9sqYWFhrFu3jsjISFq0aEH//pe8HbFSHqXlrvzW+++/zyOPPML7779PmTJlbMe5oIoVK5KcnEy3bt1o2LAhrVu3th1JBQnf2tRRyk0HDx4kNjaWlStXFngPVNuaN2/OCy+8QFRUFEeOHLEdRwUJLXfld86cOUNUVBTjxo2je/futuO4pU+fPgwaNIiYmBgyMzNtx1FBQMtd+RVjDCNHjqRBgwY8+OCDtuNclscee4xy5coxbtw421FUENByV37lmWee4fPPP2fp0qUeuza7t4SEhPDKK6/w9ttvs2TJEttxVIDTCVXlN/79738zZ84cdu7cScmSJW3HuSJlypQhJSWFDh060KRJE2666SbbkVSA0i135Rf27t3LoEGDWLt2LTVr1rQd56o0aNCAFStW0KdPHw4dOmQ7jgpQbpW7iHQXkS9FZK+ITLzA6zVF5G0R2SUi/xWRHp6PqoLVr7/+isPhYPr06XTs2NF2HI+44447uO+++4iKiuLMmTO246gAVGC5i0gosBC4A2gC9BeRJucNewRYZ4xpBfQDXvB0UBWccnNzGTRoEB06dGD06NG243jUQw89RL169Rg1apReA155nDtb7pHAXmPMfmNMJpAIOM4bY4DfziIpC3znuYgqmD322GMcO3aM+fPn+90EakFEhGXLlrF7926effZZ23FUgHFnQrU6cDDf40PA+fctmw78W0TuAcKBWzySTgW1pKQkli9fTmpqKkWLFrUdp1CULFmSpKQk2rVrR7Nmzbj11lttR1IBwlMTqv2Bl40x1wE9gFUi8qdli8goEUkXkfSjR4966KNVIPrss88YNWoUmzZtokqVKrbjFKpatWqRmJjIwIED2bdvn+04KkC4U+6HgRr5Hl+X91x+w4F1AMaY7UBxoOL5CzLGLDbGRBhjIipVqnRliVXAO378OE6nk2effZaIiAjbcbyiU6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w53bt3tx1J+QDdclce98knn3DXXXeRlJRE5cqVbccJCjVq1GDdunXEx8fz1Vdf2Y6jfICWu/KoY8eOERUVxfPPP0/r1q1txwkqHTp0YObMmTgcDn755RfbcZRlWu7KY7KysoiNjSU2Npb+/fvbjhOURo0aRZcuXRg4cKDeZDvIabkrj5kwYQLFixfn8ccftx0lqM2bN4+TJ08ybdo021GURTqhqjzipZde4p///CepqamEhobajhPUihYtyoYNG2jTpg0tWrQgJibGdiRlgZa7umo7duzg4YcfZtu2bZQrV852HAVUrlyZpKQkbr/9dho0aEDz5s1tR1Jeprtl1FX57rvviImJYdmyZTRu3Nh2HJVP69atef7553E6nRw7dsx2HOVlWu7qip09e5bo6GjGjBnD3/72N9tx1AX079+fPn360LdvX73JdpDRcldXxBjDmDFjqFGjBpMnT7YdR13CE088QdGiRZkwYYLtKMqLdJ+7uiLz58/nP//5Dx988IFem93HhYaG8uqrr9K2bVtatGjB0KFDbUdSXqDlri7b1q1beeKJJ9i+fTulSpWyHUe54ZprriElJYVOnTrRpEkT2rZtazuSKmS6W0ZdlgMHDjBgwABeffVV6tSpYzuOugyNGzdm6dKl9O7dm++++852HFXI3Cp3EekuIl+KyF4RmXiRMbEi8rmI7BaRVz0bU/mCjIwMnE4nkydPpmvXrrbjqCvQq1cvRo8eTe/evTl37pztOKoQSUHXgBaRUOAr4FbgEJAG9DfGfJ5vTH1gHdDVGHNCRCobY45carkREREmPT39avMrLzHGEBsbS6lSpVi+fLnuZ/djxhj69OlDmTJlWLZsmf6/9DMi8pExJqKgce5suUcCe40x+40xmUAi4DhvzEhgoTHmBEBBxa78zxNPPMHBgwdZtGiRloGfExFefvll0tPTWbBgge04qpC4M6FaHTiY7/Eh4PzZmAYAIvIBEApMN8b8yyMJlXX/+Mc/WLRoEampqRQvXtx2HOUBpUqVIiUlhfbt23P99dfTpUsX25GUh3lqQrUIUB/oDPQHlojIn85DF5FRIpIuIulHjx710EerwrRnzx6GDx/Ohg0bqFatmu04yoPq1KnD6tW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wVUQ+Ncbs83RWFbD+AawxxpwTkTtx/Wunq+VMQc9ny90Yc8tVLuIwkH8L4rq85wLKpdaTiPwoIlWNMd/n/fPvyEWWcTjvv/tF5B2gFRDo5e7O98dvYw6JSBGgLPCTd+L5jALXkzEm/zpZCsz2Qi5/5NVOCuTdMmlAfRGpIyJFgX5A0BwJkmczMDjv68HAn/7FIyLXiEixvK8rAjcBn3stoT3ufH/kX38xwFYTfCeGFLiezttv3AvY48V8/mQzEJ931Ew74Od8u009zxjjd3+AKFz7q84BPwJb8p6vBryeb1wP4CtcW6FTbOe2sJ4q4DpK5mvgTaB83vMRwNK8r28EPgU+yfvvcNu5vbh+/vT9ATwG9Mr7ujiwHtgLpAJ1bWf20fX0JLA773vobaCR7cyW1tMa4HsgK6+fhgOjgdF5rwuuI4/25f2sRRRmHj1DVSmlAlAg75ZRSqmgpeWulFIBSMtdKaUCkJa7UkoFIC13pZQKQFruSikVgLTclVIqAGm5K6VUAPr/WBdBJS7gHWwAAAAASUVORK5CYII=\n", "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# prepare graph data\n", "node_datasource = [1, 2, 3]\n", "edge_datasource = [(1, 2), (1, 3)]\n", "\n", "G = nx.Graph()\n", "G.add_nodes_from(node_datasource)\n", "G.add_edges_from(edge_datasource)\n", "\n", "# prepare position data\n", "fixed_layout = {1: [0, 1],\n", " 2: [-1, 0],\n", " 3: [1, 0]}\n", "\n", "# show \n", "fig = plt.figure()\n", "nx.draw_networkx_nodes(G, pos=fixed_layout, alpha=0.5)\n", "nx.draw_networkx_labels(G, pos=fixed_layout)\n", "nx.draw_networkx_edges(G, pos=fixed_layout)\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2018-09-23T03:06:03.104222Z", "start_time": "2018-09-23T03:06:03.100310Z" } }, "source": [ "## Convert to Bokeh" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:21.424027Z", "start_time": "2018-09-23T04:05:21.204208Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " root._bokeh_onload_callbacks = [];\n", " root._bokeh_is_loading = undefined;\n", " }\n", "\n", " var JS_MIME_TYPE = 'application/javascript';\n", " var HTML_MIME_TYPE = 'text/html';\n", " var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", " var CLASS_NAME = 'output_bokeh rendered_html';\n", "\n", " /**\n", " * Render data to the DOM node\n", " */\n", " function render(props, node) {\n", " var script = document.createElement(\"script\");\n", " node.appendChild(script);\n", " }\n", "\n", " /**\n", " * Handle when an output is cleared or removed\n", " */\n", " function handleClearOutput(event, handle) {\n", " var cell = handle.cell;\n", "\n", " var id = cell.output_area._bokeh_element_id;\n", " var server_id = cell.output_area._bokeh_server_id;\n", " // Clean up Bokeh references\n", " if (id != null && id in Bokeh.index) {\n", " Bokeh.index[id].model.document.clear();\n", " delete Bokeh.index[id];\n", " }\n", "\n", " if (server_id !== undefined) {\n", " // Clean up Bokeh references\n", " var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", " cell.notebook.kernel.execute(cmd, {\n", " iopub: {\n", " output: function(msg) {\n", " var id = msg.content.text.trim();\n", " if (id in Bokeh.index) {\n", " Bokeh.index[id].model.document.clear();\n", " delete Bokeh.index[id];\n", " }\n", " }\n", " }\n", " });\n", " // Destroy server and session\n", " var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", " cell.notebook.kernel.execute(cmd);\n", " }\n", " }\n", "\n", " /**\n", " * Handle when a new output is added\n", " */\n", " function handleAddOutput(event, handle) {\n", " var output_area = handle.output_area;\n", " var output = handle.output;\n", "\n", " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", " if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", " return\n", " }\n", "\n", " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", "\n", " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", " // store reference to embed id on output_area\n", " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", " }\n", " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", " var bk_div = document.createElement(\"div\");\n", " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", " var script_attrs = bk_div.children[0].attributes;\n", " for (var i = 0; i < script_attrs.length; i++) {\n", " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", " }\n", " // store reference to server id on output_area\n", " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", " }\n", " }\n", "\n", " function register_renderer(events, OutputArea) {\n", "\n", " function append_mime(data, metadata, element) {\n", " // create a DOM node to render to\n", " var toinsert = this.create_output_subarea(\n", " metadata,\n", " CLASS_NAME,\n", " EXEC_MIME_TYPE\n", " );\n", " this.keyboard_manager.register_events(toinsert);\n", " // Render to node\n", " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", " render(props, toinsert[toinsert.length - 1]);\n", " element.append(toinsert);\n", " return toinsert\n", " }\n", "\n", " /* Handle when an output is cleared or removed */\n", " events.on('clear_output.CodeCell', handleClearOutput);\n", " events.on('delete.Cell', handleClearOutput);\n", "\n", " /* Handle when a new output is added */\n", " events.on('output_added.OutputArea', handleAddOutput);\n", "\n", " /**\n", " * Register the mime type and append_mime function with output_area\n", " */\n", " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", " /* Is output safe? */\n", " safe: true,\n", " /* Index of renderer in `output_area.display_order` */\n", " index: 0\n", " });\n", " }\n", "\n", " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", " if (root.Jupyter !== undefined) {\n", " var events = require('base/js/events');\n", " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", "\n", " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", " register_renderer(events, OutputArea);\n", " }\n", " }\n", "\n", " \n", " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"

\\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", " \"

\\n\"+\n", " \"\\n\"+\n", " \"\\n\"+\n", " \"from bokeh.resources import INLINE\\n\"+\n", " \"output_notebook(resources=INLINE)\\n\"+\n", " \"\\n\"+\n", " \"
\"}};\n", "\n", " function display_loaded() {\n", " var el = document.getElementById(\"3016fb73-b363-4455-b0e8-67ae13a182f0\");\n", " if (el != null) {\n", " el.textContent = \"BokehJS is loading...\";\n", " }\n", " if (root.Bokeh !== undefined) {\n", " if (el != null) {\n", " el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n", " }\n", " } else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", "\n", " function run_callbacks() {\n", " try {\n", " root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " }\n", " finally {\n", " delete root._bokeh_onload_callbacks\n", " }\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " root._bokeh_onload_callbacks.push(callback);\n", " if (root._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", " root._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", " root._bokeh_is_loading--;\n", " if (root._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(\"3016fb73-b363-4455-b0e8-67ae13a182f0\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '3016fb73-b363-4455-b0e8-67ae13a182f0' but no matching script tag was found. \")\n", " return false;\n", " }\n", "\n", " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.13.0.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((root.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i].call(root, root.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!root._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " root._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"3016fb73-b363-4455-b0e8-67ae13a182f0\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (root._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", "}(window));" ], "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\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 \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"3016fb73-b363-4455-b0e8-67ae13a182f0\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._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 root._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 root._bokeh_is_loading--;\n if (root._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(\"3016fb73-b363-4455-b0e8-67ae13a182f0\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '3016fb73-b363-4455-b0e8-67ae13a182f0' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.13.0.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"3016fb73-b363-4455-b0e8-67ae13a182f0\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._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}(window));" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " \n", " var docs_json = {\"862e2f14-38a6-467e-a157-fb3f65435722\":{\"roots\":{\"references\":[{\"attributes\":{\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"f251e80e-cfc5-4095-bb50-b435ac35ffc1\",\"type\":\"GraphRenderer\"}],\"title\":{\"id\":\"02f0b625-6d57-4903-b8ef-4cc781e35da6\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"a513a4f7-9684-44d7-973a-e1891f927ce5\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"8887b381-3a41-473b-b28b-b731ee38d55d\",\"type\":\"Range1d\"},\"x_scale\":{\"id\":\"791f1083-72d0-4228-8667-3dcc4db5fb2d\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"e70df4c7-320b-49b7-a356-9dc6c3995b4b\",\"type\":\"Range1d\"},\"y_scale\":{\"id\":\"a0273f5c-b8f4-4a40-8775-81cf067903a4\",\"type\":\"LinearScale\"}},\"id\":\"a27768d3-40e2-4f06-b3c7-ca5e517a21bb\",\"type\":\"Plot\"},{\"attributes\":{\"data_source\":{\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"b318eadd-5f69-4588-8a2a-bdb5585d0c34\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"view\":{\"id\":\"b3846593-f862-4636-9219-d3326a499072\",\"type\":\"CDSView\"}},\"id\":\"a354fcbe-081d-4281-83e2-0790580f0614\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\"},\"id\":\"a513a4f7-9684-44d7-973a-e1891f927ce5\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"a0273f5c-b8f4-4a40-8775-81cf067903a4\",\"type\":\"LinearScale\"},{\"attributes\":{\"graph_layout\":{\"1\":[-1.4794485707633157e-05,0.001141941179528095],\"2\":[-0.01320913181934229,0.9988580588204719],\"3\":[0.013223926305049838,-1.0]}},\"id\":\"287bfd5b-f894-4d73-a2f8-74426457582b\",\"type\":\"StaticLayoutProvider\"},{\"attributes\":{\"source\":{\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"}},\"id\":\"f56ef473-99bd-4ae7-8449-f3984a5b81da\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"b318eadd-5f69-4588-8a2a-bdb5585d0c34\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"fe1c33c0-b5f0-4a9e-831d-83a16c06d715\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null,\"data\":{\"index\":[1,2,3]},\"selected\":{\"id\":\"eaed60f7-6fd4-4c40-897b-f01ee91806a4\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"fe1c33c0-b5f0-4a9e-831d-83a16c06d715\",\"type\":\"UnionRenderers\"}},\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"f018acce-d1db-422a-a455-6115d644de7a\",\"type\":\"Selection\"},{\"attributes\":{\"edge_renderer\":{\"id\":\"621d3c2b-0bf7-4732-8ff0-568e30b42cc0\",\"type\":\"GlyphRenderer\"},\"inspection_policy\":{\"id\":\"25968901-f9c5-4fb3-9292-e749f1468afe\",\"type\":\"NodesOnly\"},\"layout_provider\":{\"id\":\"287bfd5b-f894-4d73-a2f8-74426457582b\",\"type\":\"StaticLayoutProvider\"},\"node_renderer\":{\"id\":\"a354fcbe-081d-4281-83e2-0790580f0614\",\"type\":\"GlyphRenderer\"},\"selection_policy\":{\"id\":\"890fcd45-71f0-4bda-ba49-f83a23c94482\",\"type\":\"NodesOnly\"}},\"id\":\"f251e80e-cfc5-4095-bb50-b435ac35ffc1\",\"type\":\"GraphRenderer\"},{\"attributes\":{\"callback\":null,\"end\":1.1,\"start\":-1.1},\"id\":\"8887b381-3a41-473b-b28b-b731ee38d55d\",\"type\":\"Range1d\"},{\"attributes\":{},\"id\":\"25968901-f9c5-4fb3-9292-e749f1468afe\",\"type\":\"NodesOnly\"},{\"attributes\":{\"source\":{\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"}},\"id\":\"b3846593-f862-4636-9219-d3326a499072\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"eaed60f7-6fd4-4c40-897b-f01ee91806a4\",\"type\":\"Selection\"},{\"attributes\":{\"data_source\":{\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"46fd13a7-2748-4d87-9ce9-25589d3b4e56\",\"type\":\"MultiLine\"},\"hover_glyph\":null,\"muted_glyph\":null,\"view\":{\"id\":\"f56ef473-99bd-4ae7-8449-f3984a5b81da\",\"type\":\"CDSView\"}},\"id\":\"621d3c2b-0bf7-4732-8ff0-568e30b42cc0\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"46fd13a7-2748-4d87-9ce9-25589d3b4e56\",\"type\":\"MultiLine\"},{\"attributes\":{\"callback\":null,\"data\":{\"end\":[2,3],\"start\":[1,1]},\"selected\":{\"id\":\"f018acce-d1db-422a-a455-6115d644de7a\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"6c0289b6-2eee-4b28-a4f3-eb77ef4337a8\",\"type\":\"UnionRenderers\"}},\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"890fcd45-71f0-4bda-ba49-f83a23c94482\",\"type\":\"NodesOnly\"},{\"attributes\":{},\"id\":\"6c0289b6-2eee-4b28-a4f3-eb77ef4337a8\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"02f0b625-6d57-4903-b8ef-4cc781e35da6\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"791f1083-72d0-4228-8667-3dcc4db5fb2d\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"end\":1.1,\"start\":-1.1},\"id\":\"e70df4c7-320b-49b7-a356-9dc6c3995b4b\",\"type\":\"Range1d\"}],\"root_ids\":[\"a27768d3-40e2-4f06-b3c7-ca5e517a21bb\"]},\"title\":\"Bokeh Application\",\"version\":\"0.13.0\"}};\n", " var render_items = [{\"docid\":\"862e2f14-38a6-467e-a157-fb3f65435722\",\"roots\":{\"a27768d3-40e2-4f06-b3c7-ca5e517a21bb\":\"ff72169e-f5da-4bff-8850-d7dccea9fdf2\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", "\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " var attempts = 0;\n", " var timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " clearInterval(timer);\n", " }\n", " attempts++;\n", " if (attempts > 100) {\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n", " clearInterval(timer);\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "a27768d3-40e2-4f06-b3c7-ca5e517a21bb" } }, "output_type": "display_data" } ], "source": [ "# from_networkx requires a layout function.\n", "# Therefore, specify nx.spring_layout as a dummy.\n", "graph_renderer = from_networkx(G, nx.spring_layout)\n", "\n", "# show\n", "plot = Plot(plot_width=300, plot_height=300,\n", " x_range=Range1d(-1.1, 1.1), y_range=Range1d(-1.1, 1.1))\n", "plot.renderers.append(graph_renderer)\n", "\n", "output_notebook()\n", "show(plot)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Customize Layout\n", "- layout_provider | GraphRenderer\n", " - https://bokeh.pydata.org/en/latest/docs/reference/models/renderers.html#bokeh.models.renderers.GraphRenderer.layout_provider\n", " \n", "The following pages are helpful too. \n", "https://bokeh.pydata.org/en/latest/docs/user_guide/examples/graph_customize.html\n", "> graph_layout = dict(zip(node_indices, zip(x, y))) \n", "> graph.layout_provider = StaticLayoutProvider(graph_layout=graph_layout)\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:22.793845Z", "start_time": "2018-09-23T04:05:22.785355Z" } }, "outputs": [ { "data": { "text/plain": [ "{1: array([ -1.47944857e-05, 1.14194118e-03]),\n", " 2: array([-0.01320913, 0.99885806]),\n", " 3: array([ 0.01322393, -1. ])}" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# graph_layout seems to contain the layout of the nodes\n", "graph_renderer.layout_provider.graph_layout" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:23.449611Z", "start_time": "2018-09-23T04:05:23.441890Z" } }, "outputs": [ { "data": { "text/plain": [ "{1: [0, 1], 2: [-1, 0], 3: [1, 0]}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fixed_layout" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2018-09-23T04:05:24.386799Z", "start_time": "2018-09-23T04:05:24.265550Z" } }, "outputs": [ { "data": { "text/html": [ "\n", "
\n", " \n", " Loading BokehJS ...\n", "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", "(function(root) {\n", " function now() {\n", " return new Date();\n", " }\n", "\n", " var force = true;\n", "\n", " if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n", " root._bokeh_onload_callbacks = [];\n", " root._bokeh_is_loading = undefined;\n", " }\n", "\n", " var JS_MIME_TYPE = 'application/javascript';\n", " var HTML_MIME_TYPE = 'text/html';\n", " var EXEC_MIME_TYPE = 'application/vnd.bokehjs_exec.v0+json';\n", " var CLASS_NAME = 'output_bokeh rendered_html';\n", "\n", " /**\n", " * Render data to the DOM node\n", " */\n", " function render(props, node) {\n", " var script = document.createElement(\"script\");\n", " node.appendChild(script);\n", " }\n", "\n", " /**\n", " * Handle when an output is cleared or removed\n", " */\n", " function handleClearOutput(event, handle) {\n", " var cell = handle.cell;\n", "\n", " var id = cell.output_area._bokeh_element_id;\n", " var server_id = cell.output_area._bokeh_server_id;\n", " // Clean up Bokeh references\n", " if (id != null && id in Bokeh.index) {\n", " Bokeh.index[id].model.document.clear();\n", " delete Bokeh.index[id];\n", " }\n", "\n", " if (server_id !== undefined) {\n", " // Clean up Bokeh references\n", " var cmd = \"from bokeh.io.state import curstate; print(curstate().uuid_to_server['\" + server_id + \"'].get_sessions()[0].document.roots[0]._id)\";\n", " cell.notebook.kernel.execute(cmd, {\n", " iopub: {\n", " output: function(msg) {\n", " var id = msg.content.text.trim();\n", " if (id in Bokeh.index) {\n", " Bokeh.index[id].model.document.clear();\n", " delete Bokeh.index[id];\n", " }\n", " }\n", " }\n", " });\n", " // Destroy server and session\n", " var cmd = \"import bokeh.io.notebook as ion; ion.destroy_server('\" + server_id + \"')\";\n", " cell.notebook.kernel.execute(cmd);\n", " }\n", " }\n", "\n", " /**\n", " * Handle when a new output is added\n", " */\n", " function handleAddOutput(event, handle) {\n", " var output_area = handle.output_area;\n", " var output = handle.output;\n", "\n", " // limit handleAddOutput to display_data with EXEC_MIME_TYPE content only\n", " if ((output.output_type != \"display_data\") || (!output.data.hasOwnProperty(EXEC_MIME_TYPE))) {\n", " return\n", " }\n", "\n", " var toinsert = output_area.element.find(\".\" + CLASS_NAME.split(' ')[0]);\n", "\n", " if (output.metadata[EXEC_MIME_TYPE][\"id\"] !== undefined) {\n", " toinsert[toinsert.length - 1].firstChild.textContent = output.data[JS_MIME_TYPE];\n", " // store reference to embed id on output_area\n", " output_area._bokeh_element_id = output.metadata[EXEC_MIME_TYPE][\"id\"];\n", " }\n", " if (output.metadata[EXEC_MIME_TYPE][\"server_id\"] !== undefined) {\n", " var bk_div = document.createElement(\"div\");\n", " bk_div.innerHTML = output.data[HTML_MIME_TYPE];\n", " var script_attrs = bk_div.children[0].attributes;\n", " for (var i = 0; i < script_attrs.length; i++) {\n", " toinsert[toinsert.length - 1].firstChild.setAttribute(script_attrs[i].name, script_attrs[i].value);\n", " }\n", " // store reference to server id on output_area\n", " output_area._bokeh_server_id = output.metadata[EXEC_MIME_TYPE][\"server_id\"];\n", " }\n", " }\n", "\n", " function register_renderer(events, OutputArea) {\n", "\n", " function append_mime(data, metadata, element) {\n", " // create a DOM node to render to\n", " var toinsert = this.create_output_subarea(\n", " metadata,\n", " CLASS_NAME,\n", " EXEC_MIME_TYPE\n", " );\n", " this.keyboard_manager.register_events(toinsert);\n", " // Render to node\n", " var props = {data: data, metadata: metadata[EXEC_MIME_TYPE]};\n", " render(props, toinsert[toinsert.length - 1]);\n", " element.append(toinsert);\n", " return toinsert\n", " }\n", "\n", " /* Handle when an output is cleared or removed */\n", " events.on('clear_output.CodeCell', handleClearOutput);\n", " events.on('delete.Cell', handleClearOutput);\n", "\n", " /* Handle when a new output is added */\n", " events.on('output_added.OutputArea', handleAddOutput);\n", "\n", " /**\n", " * Register the mime type and append_mime function with output_area\n", " */\n", " OutputArea.prototype.register_mime_type(EXEC_MIME_TYPE, append_mime, {\n", " /* Is output safe? */\n", " safe: true,\n", " /* Index of renderer in `output_area.display_order` */\n", " index: 0\n", " });\n", " }\n", "\n", " // register the mime type if in Jupyter Notebook environment and previously unregistered\n", " if (root.Jupyter !== undefined) {\n", " var events = require('base/js/events');\n", " var OutputArea = require('notebook/js/outputarea').OutputArea;\n", "\n", " if (OutputArea.prototype.mime_types().indexOf(EXEC_MIME_TYPE) == -1) {\n", " register_renderer(events, OutputArea);\n", " }\n", " }\n", "\n", " \n", " if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n", " root._bokeh_timeout = Date.now() + 5000;\n", " root._bokeh_failed_load = false;\n", " }\n", "\n", " var NB_LOAD_WARNING = {'data': {'text/html':\n", " \"
\\n\"+\n", " \"

\\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", " \"

\\n\"+\n", " \"\\n\"+\n", " \"\\n\"+\n", " \"from bokeh.resources import INLINE\\n\"+\n", " \"output_notebook(resources=INLINE)\\n\"+\n", " \"\\n\"+\n", " \"
\"}};\n", "\n", " function display_loaded() {\n", " var el = document.getElementById(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\");\n", " if (el != null) {\n", " el.textContent = \"BokehJS is loading...\";\n", " }\n", " if (root.Bokeh !== undefined) {\n", " if (el != null) {\n", " el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n", " }\n", " } else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(display_loaded, 100)\n", " }\n", " }\n", "\n", "\n", " function run_callbacks() {\n", " try {\n", " root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n", " }\n", " finally {\n", " delete root._bokeh_onload_callbacks\n", " }\n", " console.info(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(js_urls, callback) {\n", " root._bokeh_onload_callbacks.push(callback);\n", " if (root._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", " root._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", " root._bokeh_is_loading--;\n", " if (root._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(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\");\n", " if (element == null) {\n", " console.log(\"Bokeh: ERROR: autoload.js configured with elementid '6901bb9d-d0be-4dd0-94ed-645f7cf45d6b' but no matching script tag was found. \")\n", " return false;\n", " }\n", "\n", " var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.13.0.min.js\"];\n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " \n", " function(Bokeh) {\n", " \n", " },\n", " function(Bokeh) {\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n", " console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n", " Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if ((root.Bokeh !== undefined) || (force === true)) {\n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i].call(root, root.Bokeh);\n", " }if (force === true) {\n", " display_loaded();\n", " }} else if (Date.now() < root._bokeh_timeout) {\n", " setTimeout(run_inline_js, 100);\n", " } else if (!root._bokeh_failed_load) {\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " root._bokeh_failed_load = true;\n", " } else if (force !== true) {\n", " var cell = $(document.getElementById(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\")).parents('.cell').data().cell;\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " }\n", "\n", " }\n", "\n", " if (root._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", "}(window));" ], "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof (root._bokeh_onload_callbacks) === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"
\\n\"+\n \"

\\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 \"

\\n\"+\n \"\\n\"+\n \"\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"\\n\"+\n \"
\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) { callback() });\n }\n finally {\n delete root._bokeh_onload_callbacks\n }\n console.info(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(js_urls, callback) {\n root._bokeh_onload_callbacks.push(callback);\n if (root._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 root._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 root._bokeh_is_loading--;\n if (root._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(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\");\n if (element == null) {\n console.log(\"Bokeh: ERROR: autoload.js configured with elementid '6901bb9d-d0be-4dd0-94ed-645f7cf45d6b' but no matching script tag was found. \")\n return false;\n }\n\n var js_urls = [\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.js\", \"https://cdn.pydata.org/bokeh/release/bokeh-gl-0.13.0.min.js\"];\n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n \n function(Bokeh) {\n \n },\n function(Bokeh) {\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-0.13.0.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.13.0.min.css\");\n console.log(\"Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh/release/bokeh-tables-0.13.0.min.css\");\n }\n ];\n\n function run_inline_js() {\n \n if ((root.Bokeh !== undefined) || (force === true)) {\n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"6901bb9d-d0be-4dd0-94ed-645f7cf45d6b\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._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}(window));" }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "\n", "
\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "(function(root) {\n", " function embed_document(root) {\n", " \n", " var docs_json = {\"739810ca-76cf-4d5e-b455-2b527ea5fa99\":{\"roots\":{\"references\":[{\"attributes\":{\"graph_layout\":{\"1\":[0,1],\"2\":[-1,0],\"3\":[1,0]}},\"id\":\"e9a5509e-141f-4c46-b188-c87de94f588e\",\"type\":\"StaticLayoutProvider\"},{\"attributes\":{\"callback\":null,\"end\":1.1,\"start\":-1.1},\"id\":\"3c49f69a-fa64-4dd0-b796-5d2e0b5dd08f\",\"type\":\"Range1d\"},{\"attributes\":{\"data_source\":{\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"b318eadd-5f69-4588-8a2a-bdb5585d0c34\",\"type\":\"Circle\"},\"hover_glyph\":null,\"muted_glyph\":null,\"view\":{\"id\":\"b3846593-f862-4636-9219-d3326a499072\",\"type\":\"CDSView\"}},\"id\":\"a354fcbe-081d-4281-83e2-0790580f0614\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"callback\":null,\"end\":1.1,\"start\":-1.1},\"id\":\"474450e7-dce5-4dcd-ac8b-b6636603a4f5\",\"type\":\"Range1d\"},{\"attributes\":{\"source\":{\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"}},\"id\":\"f56ef473-99bd-4ae7-8449-f3984a5b81da\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"b318eadd-5f69-4588-8a2a-bdb5585d0c34\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"fe1c33c0-b5f0-4a9e-831d-83a16c06d715\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"callback\":null,\"data\":{\"index\":[1,2,3]},\"selected\":{\"id\":\"eaed60f7-6fd4-4c40-897b-f01ee91806a4\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"fe1c33c0-b5f0-4a9e-831d-83a16c06d715\",\"type\":\"UnionRenderers\"}},\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"f018acce-d1db-422a-a455-6115d644de7a\",\"type\":\"Selection\"},{\"attributes\":{\"edge_renderer\":{\"id\":\"621d3c2b-0bf7-4732-8ff0-568e30b42cc0\",\"type\":\"GlyphRenderer\"},\"inspection_policy\":{\"id\":\"25968901-f9c5-4fb3-9292-e749f1468afe\",\"type\":\"NodesOnly\"},\"layout_provider\":{\"id\":\"e9a5509e-141f-4c46-b188-c87de94f588e\",\"type\":\"StaticLayoutProvider\"},\"node_renderer\":{\"id\":\"a354fcbe-081d-4281-83e2-0790580f0614\",\"type\":\"GlyphRenderer\"},\"selection_policy\":{\"id\":\"890fcd45-71f0-4bda-ba49-f83a23c94482\",\"type\":\"NodesOnly\"}},\"id\":\"f251e80e-cfc5-4095-bb50-b435ac35ffc1\",\"type\":\"GraphRenderer\"},{\"attributes\":{},\"id\":\"25968901-f9c5-4fb3-9292-e749f1468afe\",\"type\":\"NodesOnly\"},{\"attributes\":{\"plot_height\":300,\"plot_width\":300,\"renderers\":[{\"id\":\"f251e80e-cfc5-4095-bb50-b435ac35ffc1\",\"type\":\"GraphRenderer\"}],\"title\":{\"id\":\"411ab92a-6dde-452e-b66f-0c5c7f1f3278\",\"type\":\"Title\"},\"toolbar\":{\"id\":\"473c60cc-3625-4df0-bc4e-b9f6c63d9d7d\",\"type\":\"Toolbar\"},\"x_range\":{\"id\":\"3c49f69a-fa64-4dd0-b796-5d2e0b5dd08f\",\"type\":\"Range1d\"},\"x_scale\":{\"id\":\"f5a2150c-a8ba-426f-a7c8-087e5b2472c9\",\"type\":\"LinearScale\"},\"y_range\":{\"id\":\"474450e7-dce5-4dcd-ac8b-b6636603a4f5\",\"type\":\"Range1d\"},\"y_scale\":{\"id\":\"36ca1604-1ff6-4ab5-b432-9e9b1b220e54\",\"type\":\"LinearScale\"}},\"id\":\"5957b5d3-95b6-494f-a3ef-17ec861cc87d\",\"type\":\"Plot\"},{\"attributes\":{\"source\":{\"id\":\"e218647b-79f2-4d95-8459-45433a2a5c2b\",\"type\":\"ColumnDataSource\"}},\"id\":\"b3846593-f862-4636-9219-d3326a499072\",\"type\":\"CDSView\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\"},\"id\":\"473c60cc-3625-4df0-bc4e-b9f6c63d9d7d\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"eaed60f7-6fd4-4c40-897b-f01ee91806a4\",\"type\":\"Selection\"},{\"attributes\":{\"plot\":null,\"text\":\"\"},\"id\":\"411ab92a-6dde-452e-b66f-0c5c7f1f3278\",\"type\":\"Title\"},{\"attributes\":{\"data_source\":{\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"},\"glyph\":{\"id\":\"46fd13a7-2748-4d87-9ce9-25589d3b4e56\",\"type\":\"MultiLine\"},\"hover_glyph\":null,\"muted_glyph\":null,\"view\":{\"id\":\"f56ef473-99bd-4ae7-8449-f3984a5b81da\",\"type\":\"CDSView\"}},\"id\":\"621d3c2b-0bf7-4732-8ff0-568e30b42cc0\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"46fd13a7-2748-4d87-9ce9-25589d3b4e56\",\"type\":\"MultiLine\"},{\"attributes\":{},\"id\":\"f5a2150c-a8ba-426f-a7c8-087e5b2472c9\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"890fcd45-71f0-4bda-ba49-f83a23c94482\",\"type\":\"NodesOnly\"},{\"attributes\":{\"callback\":null,\"data\":{\"end\":[2,3],\"start\":[1,1]},\"selected\":{\"id\":\"f018acce-d1db-422a-a455-6115d644de7a\",\"type\":\"Selection\"},\"selection_policy\":{\"id\":\"6c0289b6-2eee-4b28-a4f3-eb77ef4337a8\",\"type\":\"UnionRenderers\"}},\"id\":\"59e89f19-4954-4d2d-996c-2114ef1657b4\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"36ca1604-1ff6-4ab5-b432-9e9b1b220e54\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"6c0289b6-2eee-4b28-a4f3-eb77ef4337a8\",\"type\":\"UnionRenderers\"}],\"root_ids\":[\"5957b5d3-95b6-494f-a3ef-17ec861cc87d\"]},\"title\":\"Bokeh Application\",\"version\":\"0.13.0\"}};\n", " var render_items = [{\"docid\":\"739810ca-76cf-4d5e-b455-2b527ea5fa99\",\"roots\":{\"5957b5d3-95b6-494f-a3ef-17ec861cc87d\":\"d9af42ab-8d9b-4b39-97f7-39d2c5645c68\"}}];\n", " root.Bokeh.embed.embed_items_notebook(docs_json, render_items);\n", "\n", " }\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " } else {\n", " var attempts = 0;\n", " var timer = setInterval(function(root) {\n", " if (root.Bokeh !== undefined) {\n", " embed_document(root);\n", " clearInterval(timer);\n", " }\n", " attempts++;\n", " if (attempts > 100) {\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\")\n", " clearInterval(timer);\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "5957b5d3-95b6-494f-a3ef-17ec861cc87d" } }, "output_type": "display_data" } ], "source": [ "# !!! Update graph_layout with fixed position !!!\n", "fixed_layout_provider = StaticLayoutProvider(graph_layout=fixed_layout)\n", "graph_renderer.layout_provider = fixed_layout_provider\n", "\n", "plot = Plot(plot_width=300, plot_height=300,\n", " x_range=Range1d(-1.1, 1.1), y_range=Range1d(-1.1, 1.1))\n", "plot.renderers.append(graph_renderer)\n", "\n", "output_notebook()\n", "show(plot)" ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Environment (conda_nx2_env)", "language": "python", "name": "conda_nx2_env" }, "toc": { "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "toc_cell": false, "toc_position": {}, "toc_section_display": "block", "toc_window_display": false }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }