{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Introduction to plotting with Bokeh\n", "\n", "[Data set download](https://s3.amazonaws.com/bebi103.caltech.edu/data/gfmt_sleep.csv)\n", "\n", "
" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "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", " toinsert[toinsert.length - 1].firstChild.textContent = bk_div.children[0].textContent\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(\"1001\");\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) {\n", " if (callback != null)\n", " callback();\n", " });\n", " } finally {\n", " delete root._bokeh_onload_callbacks\n", " }\n", " console.debug(\"Bokeh: all callbacks have finished\");\n", " }\n", "\n", " function load_libs(css_urls, js_urls, callback) {\n", " if (css_urls == null) css_urls = [];\n", " if (js_urls == null) js_urls = [];\n", "\n", " root._bokeh_onload_callbacks.push(callback);\n", " if (root._bokeh_is_loading > 0) {\n", " console.debug(\"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.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n", " root._bokeh_is_loading = css_urls.length + js_urls.length;\n", "\n", " function on_load() {\n", " root._bokeh_is_loading--;\n", " if (root._bokeh_is_loading === 0) {\n", " console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n", " run_callbacks()\n", " }\n", " }\n", "\n", " function on_error() {\n", " console.error(\"failed to load \" + url);\n", " }\n", "\n", " for (var i = 0; i < css_urls.length; i++) {\n", " var url = css_urls[i];\n", " const element = document.createElement(\"link\");\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.rel = \"stylesheet\";\n", " element.type = \"text/css\";\n", " element.href = url;\n", " console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n", " document.body.appendChild(element);\n", " }\n", "\n", " const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js\": \"qkRvDQVAIfzsJo40iRBbxt6sttt0hv4lh74DG7OK4MCHv4C5oohXYoHUM5W11uqS\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js\": \"Sb7Mr06a9TNlet/GEBeKaf5xH3eb6AlCzwjtU82wNPyDrnfoiVl26qnvlKjmcAd+\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js\": \"HaJ15vgfmcfRtB4c4YBOI4f1MUujukqInOWVqZJZZGK7Q+ivud0OKGSTn/Vm2iso\"};\n", "\n", " for (var i = 0; i < js_urls.length; i++) {\n", " var url = js_urls[i];\n", " var element = document.createElement('script');\n", " element.onload = on_load;\n", " element.onerror = on_error;\n", " element.async = false;\n", " element.src = url;\n", " if (url in hashes) {\n", " element.crossOrigin = \"anonymous\";\n", " element.integrity = \"sha384-\" + hashes[url];\n", " }\n", " console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n", " document.head.appendChild(element);\n", " }\n", " };\n", "\n", " function inject_raw_css(css) {\n", " const element = document.createElement(\"style\");\n", " element.appendChild(document.createTextNode(css));\n", " document.body.appendChild(element);\n", " }\n", "\n", " \n", " var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js\"];\n", " var css_urls = [];\n", " \n", "\n", " var inline_js = [\n", " function(Bokeh) {\n", " Bokeh.set_log_level(\"info\");\n", " },\n", " function(Bokeh) {\n", " \n", " \n", " }\n", " ];\n", "\n", " function run_inline_js() {\n", " \n", " if (root.Bokeh !== undefined || force === true) {\n", " \n", " for (var i = 0; i < inline_js.length; i++) {\n", " inline_js[i].call(root, root.Bokeh);\n", " }\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(\"1001\")).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.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n", " run_inline_js();\n", " } else {\n", " load_libs(css_urls, js_urls, function() {\n", " console.debug(\"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(\"1001\");\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) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"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.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error() {\n console.error(\"failed to load \" + url);\n }\n\n for (var i = 0; i < css_urls.length; i++) {\n var url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error;\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js\": \"qkRvDQVAIfzsJo40iRBbxt6sttt0hv4lh74DG7OK4MCHv4C5oohXYoHUM5W11uqS\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js\": \"Sb7Mr06a9TNlet/GEBeKaf5xH3eb6AlCzwjtU82wNPyDrnfoiVl26qnvlKjmcAd+\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js\": \"HaJ15vgfmcfRtB4c4YBOI4f1MUujukqInOWVqZJZZGK7Q+ivud0OKGSTn/Vm2iso\"};\n\n for (var i = 0; i < js_urls.length; i++) {\n var url = js_urls[i];\n var element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error;\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.2.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.2.1.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.2.1.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\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(\"1001\")).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.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Colab setup ------------------\n", "import os, sys, subprocess\n", "if \"google.colab\" in sys.modules:\n", " cmd = \"pip install --upgrade watermark\"\n", " process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n", " stdout, stderr = process.communicate()\n", " data_path = \"https://s3.amazonaws.com/bebi103.caltech.edu/data/\"\n", "else:\n", " data_path = \"../data/\"\n", "# ------------------------------\n", "\n", "import numpy as np\n", "import scipy.special\n", "import pandas as pd\n", "\n", "# Our main plotting package (must have explicit import of submodules)\n", "import bokeh.io\n", "import bokeh.plotting\n", "\n", "# Enable viewing Bokeh plots in the notebook\n", "bokeh.io.output_notebook()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "We have a couple nice data sets from the last few lessons, the data from the tongue strikes of frogs and facial matching data from people with sleep deprivation. We've learned how to use Pandas to handle the data sets and get what we want out of them. But I argue that what we want out of them most of the time is **plots**. Now is the time in when we learn how to take data set and plot them." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Python visualization landscape\n", "\n", "Let us start by looking at some of the many plotting packages available in Python. In a [talk at PyCon in 2017](https://www.youtube.com/watch?v=FytuB8nFHPQ), [Jake VanderPlas](http://vanderplas.com), who is one of the authors of one of them ([Altair](https://altair-viz.github.io)), gave an overview of the Python visualization landscape. That landscape is depicted below, taken from [this visualization of it](https://github.com/rougier/python-visualization-landscape) by [Nicolas Rougier](http://www.labri.fr/perso/nrougier/). (It is three years old and definitely not complete, notably missing [Panel](https://panel.pyviz.org), for example.)\n", "\n", "![python_viz_landscape](python_viz_landscape.png)\n", "\n", "The landscape is divided into three main pods based on the low-level renderer of the graphics, JavaScript, [Matplotlib](https://matplotlib.org), and [OpenGL](https://www.opengl.org) (though Matplotlib is higher-level than JavaScript and OpenGL). We will not discuss packages based on OpenGL. Packages that use JavaScript for rendering are particularly well suited for interactivity in browsers. Interactivity and portability (accomplished by rendering in browsers) are key features of modern plotting libraries, so we will use JavaScript-based plotting (as I do in my own work)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## High-level and low-level plotting packages\n", "\n", "As a demonstration of what I mean by high-level and low-level plotting packages, let us first think about one of our tasks we did with Pandas with the facial matching data set. We computed the median percent correct for those with and without insomnia. Here's the code to do it." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "insomnia\n", "False 85.0\n", "True 75.0\n", "Name: percent correct, dtype: float64" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fname = os.path.join(data_path, \"gfmt_sleep.csv\")\n", "df = pd.read_csv(fname, na_values=\"*\")\n", "df[\"insomnia\"] = df[\"sci\"] <= 16\n", "\n", "df.groupby(\"insomnia\")[\"percent correct\"].median()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Literally just a few lines of code. Now what if we tried to do it without Pandas? I won't even go through the many lines of code necessary to read in the data. Consider just this one line.\n", "\n", "```python\n", "df.groupby('insomnia')['percent correct'].median()\n", "```\n", "\n", "There are elementary tasks that go into it if we were to code it up without using Pandas's delicious functionality. We can loop over the rows in the data frame with a `for` loop, check to see what the value of the `insomnia` column is with an `if` statement, put the value in the `percent correct` field into an appropriate array based on whether or not the subject suffers from insomnia, and then, given those arrays, sort them and pull out the middle value. Under the hood, all of those steps take place, but because we use Pandas's **high-level functionality**, those details are invisible to us, and glad we are of that.\n", "\n", "Now, say we want to make a plot of some data. You can imagine that there are many many steps to building that. One way you could build a plot is to hand-generate an [SVG file](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) that is a set of specifications for lines and circles and text and whatnot that comprises a plot. (I have actually done this before, writing a C program that hand-generated SVG, and it was paaaaainful.) That would be a very **low-level** way of generating a plot. Plotting libraries in Python usually take care of the rendering part for you, either rendering the plot as SVG, PDF, PNG, or other formats, including interactive ones that use [JavaScript](https://en.wikipedia.org/wiki/JavaScript) and [HTML Canvas](https://en.wikipedia.org/wiki/Canvas_element) that can be viewed in a browser. The plotting libraries then vary in their level of abstraction from the data set.\n", "\n", "Lower-level plotting libraries typically are more customizable, but require more [boilerplate code](https://en.wikipedia.org/wiki/Boilerplate_code) to get your data plotted and are therefore more cumbersome. Higher-level plotting libraries aim to make it easier to move directly from a data frame. Because of this streamlining, though, they are often more difficult to customize.\n", "\n", "The developers of [HoloViz](http://holoviz.org/) made a nice graphic for this concept.\n", "\n", "
\n", "\n", "![HoloViz maze](shortcuts.png)\n", "*Copyright HoloViz authors, downloaded from [here](http://holoviz.org/background.html).*\n", "\n", "
\n", "\n", "Using a low-level plotting library, you can get to any graphic you like, but it takes many steps to do so. Using a high level library, you can rapidly get to many, if not most, of the graphics you like in very few steps. However, you cannot get to *all* graphics. In a layered approach, in which the higher level libraries give you access to the lower level customizations, you can get to any graphic, and can do so quickly. The layered approach requires proficiency in using the low-level and high-level libraries." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction to Bokeh\n", "\n", "Our debate in building this course was about whether to start with higher-level plotting or lower-level. We decided to do our plotting using [Bokeh](https://bokeh.pydata.org/), a low-level plotting library first for a few reasons.\n", "\n", "1. Though low-level, generating plot you might like to construct is fairly straightforward. (Read: it's not that bad for quickly making plots.)\n", "2. By being familiar with a lower-level plotting package, you can then take a layered approach as you learn a higher-level package.\n", "3. We will discuss higher-level packages in short order.\n", "\n", "Importantly, note that Bokeh's submodules often have to be explicitly imported, as we did in the code cell at the top of this notebook. Not also that if you want your plots to be viewable (and interactive) in the notebook, you need to execute\n", "\n", "```python\n", "bokeh.io.output_notebook()\n", "```\n", "\n", "at the top of the notebook (as we have done). Finally, note that we also have to have installed the PyViz JupyterLab extension, which you should have done while configuring your computer." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Bokeh's grammar and our first plot with Bokeh\n", "\n", "Constructing a plot with Bokeh consists of four main steps.\n", "\n", "1. Creating a figure on which to populate glyphs (symbols that represent data, e.g., dots for a scatter plot). Think of this figure as a \"canvas\" which sets the space on which you will \"paint\" your glyphs.\n", "2. Defining a data source (almost always a tidy data frame) that is the reference used to place the glyphs.\n", "3. Choose the kind of glyph you would like.\n", "4. Annotate the columns of data source to determine how they are used to place (and possibly color, scale, etc.) the glyph.\n", "\n", "After completing these steps, you need to render the graphic.\n", "\n", "Let's go through these steps in generating a scatter plot of confidence when incorrect versus confidence when correct for the face matching under sleep deprivation study. So you have the concrete example in mind, the final graphic will look like this:\n", "\n", "
\n", "\n", "![First bokeh plot](first_bokeh_plot.png)\n", "\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Our first step is creating a figure, our \"canvas.\" In creating the figure, we are implicitly thinking about what kind of representation for our data we want. That is, we have to specify axes and their labels. We might also want to specify the title of the figure, whether or not to have grid lines, and all sorts of other customizations. Naturally, we also want to specify the shape of the figure.\n", "\n", "(Almost) all of this is accomplished in Bokeh by making a call to `bokeh.plotting.figure()` with the appropriate keyword arguments." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "# Create the figure, stored in variable `p`\n", "p = bokeh.plotting.figure(\n", " width=400,\n", " height=300,\n", " x_axis_label=\"confidence when correct\",\n", " y_axis_label=\"condifence when incorrect\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There are many more keyword attributes you can assign, including [all of those listed in the Bokeh Plot class](https://bokeh.pydata.org/en/latest/docs/reference/models/plots.html#bokeh.models.plots.Plot) and [the additional ones listed in the Bokeh Figure class](https://bokeh.pydata.org/en/latest/docs/reference/plotting.html#bokeh.plotting.figure.Figure).\n", "\n", "2. Now that we have set up our canvas, we can decide on the data source. We will use the data frame, `df` as our data source. \n", "\n", "3. We will choose dots (or circles) as our glyph. This kind of glyph requires that we specify which column of the data source will serve to place the glyphs along the $x$-axis and which will serve to place the glyphs along the $y$-axis.\n", "\n", "4. We choose the `'confidence when correct'` column to specify the $x$-coordinate of the glyph and the `'confidence when incorrect'` column to specify the $y$-coordinate. We already made this decision when we set up our axis labels, but we did not necessarily have to make that decision at that point.\n", "\n", "Steps 2-4 are accomplished by calling one of the **glyph methods** of the Bokeh `Figure` instance, `p`. Since we are choosing dots, the appropriate method is `p.circle()`, and we use the `source`, `x`, and `y` kwargs to specify the positions of the glyphs." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
GlyphRenderer(
id = '1037', …)
data_source = ColumnDataSource(id='1033', ...),
glyph = Circle(id='1035', ...),
hover_glyph = None,
js_event_callbacks = {},
js_property_callbacks = {},
level = 'glyph',
muted = False,
muted_glyph = None,
name = None,
nonselection_glyph = Circle(id='1036', ...),
selection_glyph = None,
subscribed_events = [],
tags = [],
view = CDSView(id='1038', ...),
visible = True,
x_range_name = 'default',
y_range_name = 'default')
\n", "\n" ], "text/plain": [ "GlyphRenderer(id='1037', ...)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p.circle(\n", " source=df, \n", " x=\"confidence when correct\", \n", " y=\"confidence when incorrect\"\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have built the plot, we can render it in the notebook using `bokeh.io.show()`." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "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 = {\"fe28eca5-5fc6-43b3-9e07-9aad1176d965\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1011\"}],\"center\":[{\"id\":\"1014\"},{\"id\":\"1018\"}],\"left\":[{\"id\":\"1015\"}],\"plot_height\":300,\"plot_width\":400,\"renderers\":[{\"id\":\"1037\"}],\"title\":{\"id\":\"1042\"},\"toolbar\":{\"id\":\"1026\"},\"x_range\":{\"id\":\"1003\"},\"x_scale\":{\"id\":\"1007\"},\"y_range\":{\"id\":\"1005\"},\"y_scale\":{\"id\":\"1009\"}},\"id\":\"1002\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1047\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1016\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1048\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"overlay\":{\"id\":\"1025\"}},\"id\":\"1021\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"axis\":{\"id\":\"1015\"},\"dimension\":1,\"ticker\":null},\"id\":\"1018\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1022\",\"type\":\"SaveTool\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1019\"},{\"id\":\"1020\"},{\"id\":\"1021\"},{\"id\":\"1022\"},{\"id\":\"1023\"},{\"id\":\"1024\"}]},\"id\":\"1026\",\"type\":\"Toolbar\"},{\"attributes\":{\"data\":{\"age\":[39,42,31,35,74,61,32,62,33,53,41,36,40,24,32,40,61,42,31,28,26,45,28,44,28,42,45,16,21,18,28,38,17,25,22,41,53,43,23,19,45,43,35,24,64,36,35,43,44,29,22,46,35,53,29,31,21,42,23,54,24,21,21,43,50,53,16,67,36,34,42,46,69,31,44,25,45,47,33,18,74,21,45,37,41,41,34,39,18,31,26,66,62,22,41,46,56,23,70,24,40,33],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAKBRQAAAAAAAgFVAAAAAAADAUUAAAAAAAIBOQAAAAAAAAD9AAAAAAACAUEAAAAAAAEBQQAAAAAAAIFBAAAAAAABATkAAAAAAAEBSQAAAAAAAwFJAAAAAAADAU0AAAAAAAIBIQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBGQAAAAAAAoFZAAAAAAABAVEAAAAAAAABZQAAAAAAAgFRAAAAAAAAAWUAAAAAAAMBQQAAAAAAAwFVAAAAAAAAAUUAAAAAAAIBFQAAAAAAAAFRAAAAAAAAAS0AAAAAAAABJQAAAAAAAAFRAAAAAAACAV0AAAAAAAMBTQAAAAAAAIFNAAAAAAABAVUAAAAAAAIBRQAAAAAAA4FBAAAAAAAAATEAAAAAAAIBIQAAAAAAAoFFAAAAAAACAUEAAAAAAAIBOQAAAAAAAAFBAAAAAAACgUkAAAAAAAABUQAAAAAAAgFBAAAAAAACAUEAAAAAAAAAzQAAAAAAAgERAAAAAAADAU0AAAAAAAEBQQAAAAAAAQFNAAAAAAAAAWUAAAAAAAEBTQAAAAAAAwEdAAAAAAAAgUEAAAAAAAEBUQAAAAAAAgFFAAAAAAAAgVEAAAAAAAEBRQAAAAAAAYFNAAAAAAACAUkAAAAAAAABMQAAAAAAAYFJAAAAAAAAAUUAAAAAAAMBXQAAAAAAAAFFAAAAAAAAASUAAAAAAAEBRQAAAAAAAgEtAAAAAAABgUkAAAAAAAIBSQAAAAAAAAFdAAAAAAACgU0AAAAAAAIBWQAAAAAAAQFFAAAAAAABATUAAAAAAAIBPQAAAAAAA4FFAAAAAAABATU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AAAAAAAASUAAAAAAAABLQAAAAAAAgExAAAAAAADAQUAAAAAAAMBQQAAAAAAAgDhAAAAAAADAT0AAAAAAAIBBQAAAAAAAgEZAAAAAAAAAS0AAAAAAAIBKQAAAAAAAAFVAAAAAAADAVkAAAAAAAAA/QAAAAAAAgElAAAAAAACARUAAAAAAAIBIQAAAAAAAAD1AAAAAAAAAU0AAAAAAAABEQAAAAAAAwFNAAAAAAADAS0AAAAAAAABRQAAAAAAAQFBAAAAAAAAAUUAAAAAAAEBQQAAAAAAAAE1AAAAAAACAQUAAAAAAAMBNQAAAAAAAAElAAAAAAADAR0AAAAAAAAD4fwAAAAAAYFJAAAAAAACAUUAAAAAAAABEQAAAAAAAwFBAAAAAAAAA+H8AAAAAAMBOQAAAAAAAwFRAAAAAAAAAREAAAAAAAIBKQAAAAAAAgEtAAAAAAABAVEAAAAAAAABQQAAAAAAAwFFAAAAAAACATUAAAAAAAMBQQAAAAAAAAE1AAAAAAAAASUAAAAAAAMBWQAAAAAAAAElAAAAAAABAVUAAAAAAAABQQAAAAAAAgFRAAAAAAADATUAAAAAAAABOQAAAAAAAwFJAAAAAAADATUAAAAAAAIBSQAAAAAAAAFRAAAAAAABAVEAAAAAAAIBJQAAAAAAAQFJA\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[102]},\"correct hit percentage\":[65,90,90,100,60,80,90,45,80,100,70,90,95,85,75,40,100,70,100,100,60,100,100,65,100,80,80,70,70,90,95,90,90,100,80,90,95,95,90,55,100,65,90,55,75,100,70,90,95,95,70,80,50,65,100,85,85,90,90,90,85,85,90,95,70,95,85,95,90,90,100,80,95,100,90,100,70,90,85,80,85,40,80,90,90,80,90,75,85,100,95,60,100,85,35,95,70,70,90,70,75,85],\"correct reject percentage\":[80,90,95,75,65,20,75,90,100,50,55,100,65,75,55,100,40,90,70,50,80,95,75,25,40,65,90,80,65,100,80,95,90,100,60,80,60,90,80,60,85,65,100,100,85,80,90,85,90,55,65,75,95,80,70,90,90,90,85,70,95,75,80,75,85,75,85,75,65,90,100,90,80,95,95,100,50,100,70,75,80,40,95,80,85,75,35,70,85,85,75,85,80,95,75,80,50,85,85,80,65,40],\"ess\":[2,7,3,20,12,2,3,9,10,7,19,0,8,4,7,14,12,10,11,12,1,6,4,6,2,5,1,3,4,5,12,4,4,11,6,3,11,10,12,6,13,12,5,10,4,4,6,3,0,12,6,5,9,7,6,10,18,11,8,16,7,9,11,4,7,4,11,12,3,3,4,11,1,4,2,9,1,2,12,6,5,5,4,9,3,8,6,10,21,5,5,9,1,8,11,5,7,10,7,15,7,7],\"gender\":[\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"m\",\"f\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\"],\"index\":[0,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,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],\"insomnia\":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],\"participant number\":[8,16,18,22,27,28,30,33,34,35,38,41,46,49,55,71,76,77,78,80,89,90,93,100,101,1,2,3,4,5,6,7,9,10,11,12,13,14,15,17,19,20,21,23,24,25,26,29,31,32,36,37,39,40,42,43,44,45,48,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,79,81,82,83,84,85,86,87,88,91,92,94,95,96,97,98,99,102,103],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAIBWQAAAAAAAIFdAAAAAAADgVUAAAAAAAEBPQAAAAAAAAElAAAAAAACgVEAAAAAAAOBQQAAAAAAAgFZAAAAAAADAUkAAAAAAAEBPQAAAAAAAwFdAAAAAAAAAVEAAAAAAAABUQAAAAAAAQFBAAAAAAACAUUAAAAAAAIBRQAAAAAAAAFRAAAAAAABAVUAAAAAAAMBSQAAAAAAAgFFAAAAAAABgWEAAAAAAAOBVQAAAAAAAgEZAAAAAAACAUUAAAAAAACBSQAAAAAAAQFVAAAAAAADAUkAAAAAAAOBQQAAAAAAAwFdAAAAAAADgVUAAAAAAACBXQAAAAAAAgFZAAAAAAAAAWUAAAAAAAIBRQAAAAAAAQFVAAAAAAABgU0AAAAAAACBXQAAAAAAAQFVAAAAAAADATEAAAAAAACBXQAAAAAAAQFBAAAAAAADAV0AAAAAAAGBTQAAAAAAAAFRAAAAAAACAVkAAAAAAAABUQAAAAAAA4FVAAAAAAAAgV0AAAAAAAMBSQAAAAAAA4FBAAAAAAABgU0AAAAAAACBSQAAAAAAAIFJAAAAAAABAVUAAAAAAAOBVQAAAAAAA4FVAAAAAAACAVkAAAAAAAOBVQAAAAAAAAFRAAAAAAACAVkAAAAAAAABUQAAAAAAAQFVAAAAAAABAVUAAAAAAAGBTQAAAAAAAQFVAAAAAAABAVUAAAAAAAEBVQAAAAAAAYFNAAAAAAACAVkAAAAAAAABZQAAAAAAAQFVAAAAAAADgVUAAAAAAAGBYQAAAAAAAIFdAAAAAAAAAWUAAAAAAAABOQAAAAAAAwFdAAAAAAABgU0AAAAAAAGBTQAAAAAAAoFRAAAAAAAAAREAAAAAAAOBVQAAAAAAAQFVAAAAAAADgVUAAAAAAAGBTQAAAAAAAQE9AAAAAAAAgUkAAAAAAAEBVQAAAAAAAIFdAAAAAAABAVUAAAAAAACBSQAAAAAAAgFZAAAAAAACAVkAAAAAAAIBLQAAAAAAA4FVAAAAAAAAATkAAAAAAAGBTQAAAAAAA4FVAAAAAAADAUkAAAAAAAIBRQAAAAAAAQE9A\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[102]},\"psqi\":[13,11,9,8,9,14,9,9,12,8,5,7,12,13,13,11,4,10,6,7,8,9,7,15,7,1,5,1,5,7,7,3,3,10,4,5,2,2,2,5,2,3,3,4,9,5,2,1,4,8,2,2,6,3,1,5,7,3,6,6,1,6,4,4,3,5,2,7,4,0,5,1,1,4,1,8,4,2,7,4,1,7,4,5,6,4,2,3,4,3,1,5,2,1,1,3,6,8,8,2,4,5],\"sci\":[9,4,10,13,13,15,16,14,14,14,14,15,10,14,5,0,16,11,14,12,14,14,16,1,14,29,19,23,26,21,19,28,29,17,22,28,31,31,32,25,30,28,30,22,20,26,32,32,24,26,30,28,21,29,32,26,26,23,18,22,29,20,27,19,29,24,29,17,26,30,17,25,31,27,32,28,25,30,21,29,20,22,23,20,17,27,27,22,25,30,32,30,32,28,31,29,26,20,19,31,22,24]},\"selected\":{\"id\":\"1047\"},\"selection_policy\":{\"id\":\"1048\"}},\"id\":\"1033\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1009\",\"type\":\"LinearScale\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1036\",\"type\":\"Circle\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1025\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1012\",\"type\":\"BasicTicker\"},{\"attributes\":{},\"id\":\"1003\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1046\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis_label\":\"confidence when correct\",\"formatter\":{\"id\":\"1046\"},\"ticker\":{\"id\":\"1012\"}},\"id\":\"1011\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1007\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1005\",\"type\":\"DataRange1d\"},{\"attributes\":{\"source\":{\"id\":\"1033\"}},\"id\":\"1038\",\"type\":\"CDSView\"},{\"attributes\":{},\"id\":\"1020\",\"type\":\"WheelZoomTool\"},{\"attributes\":{},\"id\":\"1044\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"axis\":{\"id\":\"1011\"},\"ticker\":null},\"id\":\"1014\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1023\",\"type\":\"ResetTool\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1042\",\"type\":\"Title\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1035\",\"type\":\"Circle\"},{\"attributes\":{\"axis_label\":\"condifence when incorrect\",\"formatter\":{\"id\":\"1044\"},\"ticker\":{\"id\":\"1016\"}},\"id\":\"1015\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1019\",\"type\":\"PanTool\"},{\"attributes\":{\"data_source\":{\"id\":\"1033\"},\"glyph\":{\"id\":\"1035\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1036\"},\"selection_glyph\":null,\"view\":{\"id\":\"1038\"}},\"id\":\"1037\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1024\",\"type\":\"HelpTool\"}],\"root_ids\":[\"1002\"]},\"title\":\"Bokeh Application\",\"version\":\"2.2.1\"}};\n", " var render_items = [{\"docid\":\"fe28eca5-5fc6-43b3-9e07-9aad1176d965\",\"root_ids\":[\"1002\"],\"roots\":{\"1002\":\"1296a3a9-aaf6-43f4-a984-e42c8fcb1e67\"}}];\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", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1002" } }, "output_type": "display_data" } ], "source": [ "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In looking at the plot, notice a toolbar to right of the plot that enables you to zoom and pan within the plot." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Code style in plot specifications\n", "\n", "Specifications of plots often involves calls to functions with lots of keyword arguments to specify the plot, and this can get unwieldy without a clear style. You can develop your own style, maybe reading [Trey Hunner's blog post again](http://treyhunner.com/2017/07/craft-your-python-like-poetry/). I like to do the following, which is not what [Black](https://github.com/psf/black) defaults to.\n", "\n", "1. Put the function call, like `p.circle(` or `p = bokeh.plotting.figure(` on the first line.\n", "2. The closed parenthesis for the function call is on its own line, unindented.\n", "3. Any arguments are given as kwargs (even if they can also be specified as positional arguments) at one level of indentation.\n", "\n", "Note that you *cannot* use method chaining when instantiating figures or populating glyphs.\n", "\n", "If you adhere to a style, it makes your code cleaner and easier to read." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Coloring with other dimensions\n", "\n", "Let's say we wanted to make the same plot, but with orange circles for insomniacs and blue circles for normal sleepers. To do this, we take advantage of two features of Bokeh.\n", "\n", "1. We can make multiple calls to `p.circle()` to populate more and more glyphs.\n", "2. `p.circle()`, like all of the glyph methods, has many keyword arguments, including `color` and `legend_label`, which will enable us to color the glyphs and include a legend.\n", "\n", "We can loop through the data frame grouped by `'insomnia'` and populate the glyphs as we go along." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "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 = {\"d9beea30-7767-4a3f-906b-26c6f667282f\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1104\"}],\"center\":[{\"id\":\"1107\"},{\"id\":\"1111\"},{\"id\":\"1141\"}],\"left\":[{\"id\":\"1108\"}],\"plot_height\":300,\"plot_width\":400,\"renderers\":[{\"id\":\"1130\"},{\"id\":\"1147\"}],\"title\":{\"id\":\"1133\"},\"toolbar\":{\"id\":\"1119\"},\"x_range\":{\"id\":\"1096\"},\"x_scale\":{\"id\":\"1100\"},\"y_range\":{\"id\":\"1098\"},\"y_scale\":{\"id\":\"1102\"}},\"id\":\"1095\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1158\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1137\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1138\",\"type\":\"Selection\"},{\"attributes\":{\"label\":{\"value\":\"normal sleepers\"},\"renderers\":[{\"id\":\"1130\"}]},\"id\":\"1142\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1139\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1143\"}},\"id\":\"1148\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"orange\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1146\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1096\",\"type\":\"DataRange1d\"},{\"attributes\":{\"data_source\":{\"id\":\"1143\"},\"glyph\":{\"id\":\"1145\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1146\"},\"selection_glyph\":null,\"view\":{\"id\":\"1148\"}},\"id\":\"1147\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"confidence when incorrect\",\"formatter\":{\"id\":\"1135\"},\"ticker\":{\"id\":\"1109\"}},\"id\":\"1108\",\"type\":\"LinearAxis\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1118\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data\":{\"age\":[42,45,16,21,18,28,38,17,25,22,41,53,43,23,19,45,43,35,24,64,36,35,43,44,29,22,46,35,53,29,31,21,42,23,54,24,21,21,43,50,53,16,67,36,34,42,46,69,31,44,25,45,47,33,18,74,21,45,37,41,41,34,39,18,31,26,66,62,22,41,46,56,23,70,24,40,33],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAACARUAAAAAAAABUQAAAAAAAAEtAAAAAAAAASUAAAAAAAABUQAAAAAAAgFdAAAAAAADAU0AAAAAAACBTQAAAAAAAQFVAAAAAAACAUUAAAAAAAOBQQAAAAAAAAExAAAAAAACASEAAAAAAAKBRQAAAAAAAgFBAAAAAAACATkAAAAAAAABQQAAAAAAAoFJAAAAAAAAAVEAAAAAAAIBQQAAAAAAAgFBAAAAAAAAAM0AAAAAAAIBEQAAAAAAAwFNAAAAAAABAUEAAAAAAAEBTQAAAAAAAAFlAAAAAAABAU0AAAAAAAMBHQAAAAAAAIFBAAAAAAABAVEAAAAAAAIBRQAAAAAAAIFRAAAAAAABAUUAAAAAAAGBTQAAAAAAAgFJAAAAAAAAATEAAAAAAAGBSQAAAAAAAAFFAAAAAAADAV0AAAAAAAABRQAAAAAAAAElAAAAAAABAUUAAAAAAAIBLQAAAAAAAYFJAAAAAAACAUkAAAAAAAABXQAAAAAAAoFNAAAAAAACAVkAAAAAAAEBRQAAAAAAAQE1AAAAAAACAT0AAAAAAAOBRQAAAAAAAQE1AAAAAAACAUEAAAAAAAIBPQAAAAAAAoFJAAAAAAAAAU0AAAAAAAOBUQAAAAAAAgFFAAAAAAACAVUAAAAAAAMBRQAAAAAAAwE1AAAAAAADAVkAAAAAAAABZQAAAAAAAgFRAAAAAAACAUkAAAAAAAKBSQAAAAAAAAFJAAAAAAAAAVEAAAAAAAABUQAAAAAAA4FBAAAAAAABAU0AAAAAAAMBVQAAAAAAAgFFAAAAAAAAAVUAAAAAAAAA/QA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAABARkAAAAAAAMBLQAAAAAAAgExAAAAAAAAAUEAAAAAAAMBUQAAAAAAAQFVAA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FRAAAAAAACASUAAAAAAAEBSQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"correct hit percentage\":[80,80,70,70,90,95,90,90,100,80,90,95,95,90,55,100,65,90,55,75,100,70,90,95,95,70,80,50,65,100,85,85,90,90,90,85,85,90,95,70,95,85,95,90,90,100,80,95,100,90,100,70,90,85,80,85,40,80,90,90,80,90,75,85,100,95,60,100,85,35,95,70,70,90,70,75,85],\"correct reject percentage\":[65,90,80,65,100,80,95,90,100,60,80,60,90,80,60,85,65,100,100,85,80,90,85,90,55,65,75,95,80,70,90,90,90,85,70,95,75,80,75,85,75,85,75,65,90,100,90,80,95,95,100,50,100,70,75,80,40,95,80,85,75,35,70,85,85,75,85,80,95,75,80,50,85,85,80,65,40],\"ess\":[5,1,3,4,5,12,4,4,11,6,3,11,10,12,6,13,12,5,10,4,4,6,3,0,12,6,5,9,7,6,10,18,11,8,16,7,9,11,4,7,4,11,12,3,3,4,11,1,4,2,9,1,2,12,6,5,5,4,9,3,8,6,10,21,5,5,9,1,8,11,5,7,10,7,15,7,7],\"gender\":[\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"m\",\"f\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\"],\"index\":[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],\"insomnia\":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],\"participant number\":[1,2,3,4,5,6,7,9,10,11,12,13,14,15,17,19,20,21,23,24,25,26,29,31,32,36,37,39,40,42,43,44,45,48,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,79,81,82,83,84,85,86,87,88,91,92,94,95,96,97,98,99,102,103],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAEBVQAAAAAAAwFJAAAAAAADgUEAAAAAAAMBXQAAAAAAA4FVAAAAAAAAgV0AAAAAAAIBWQAAAAAAAAFlAAAAAAACAUUAAAAAAAEBVQAAAAAAAYFNAAAAAAAAgV0AAAAAAAEBVQAAAAAAAwExAAAAAAAAgV0AAAAAAAEBQQAAAAAAAwFdAAAAAAABgU0AAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAOBVQAAAAAAAIFdAAAAAAADAUkAAAAAAAOBQQAAAAAAAYFNAAAAAAAAgUkAAAAAAACBSQAAAAAAAQFVAAAAAAADgVUAAAAAAAOBVQAAAAAAAgFZAAAAAAADgVUAAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAEBVQAAAAAAAQFVAAAAAAABgU0AAAAAAAEBVQAAAAAAAQFVAAAAAAABAVUAAAAAAAGBTQAAAAAAAgFZAAAAAAAAAWUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgWEAAAAAAACBXQAAAAAAAAFlAAAAAAAAATkAAAAAAAMBXQAAAAAAAYFNAAAAAAABgU0AAAAAAAKBUQAAAAAAAAERAAAAAAADgVUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgU0AAAAAAAEBPQAAAAAAAIFJAAAAAAABAVUAAAAAAACBXQAAAAAAAQFVAAAAAAAAgUkAAAAAAAIBWQAAAAAAAgFZAAAAAAACAS0AAAAAAAOBVQAAAAAAAAE5AAAAAAABgU0AAAAAAAOBVQAAAAAAAwFJAAAAAAACAUUAAAAAAAEBPQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"psqi\":[1,5,1,5,7,7,3,3,10,4,5,2,2,2,5,2,3,3,4,9,5,2,1,4,8,2,2,6,3,1,5,7,3,6,6,1,6,4,4,3,5,2,7,4,0,5,1,1,4,1,8,4,2,7,4,1,7,4,5,6,4,2,3,4,3,1,5,2,1,1,3,6,8,8,2,4,5],\"sci\":[29,19,23,26,21,19,28,29,17,22,28,31,31,32,25,30,28,30,22,20,26,32,32,24,26,30,28,21,29,32,26,26,23,18,22,29,20,27,19,29,24,29,17,26,30,17,25,31,27,32,28,25,30,21,29,20,22,23,20,17,27,27,22,25,30,32,30,32,28,31,29,26,20,19,31,22,24]},\"selected\":{\"id\":\"1138\"},\"selection_policy\":{\"id\":\"1139\"}},\"id\":\"1126\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"confidence when correct\",\"formatter\":{\"id\":\"1137\"},\"ticker\":{\"id\":\"1105\"}},\"id\":\"1104\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1116\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1100\",\"type\":\"LinearScale\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1133\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1098\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1102\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1105\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1104\"},\"ticker\":null},\"id\":\"1107\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1113\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"axis\":{\"id\":\"1108\"},\"dimension\":1,\"ticker\":null},\"id\":\"1111\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1109\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1112\"},{\"id\":\"1113\"},{\"id\":\"1114\"},{\"id\":\"1115\"},{\"id\":\"1116\"},{\"id\":\"1117\"}]},\"id\":\"1119\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1117\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1112\",\"type\":\"PanTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1118\"}},\"id\":\"1114\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"orange\"},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1145\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1115\",\"type\":\"SaveTool\"},{\"attributes\":{\"label\":{\"value\":\"insomniacs\"},\"renderers\":[{\"id\":\"1147\"}]},\"id\":\"1160\",\"type\":\"LegendItem\"},{\"attributes\":{\"data\":{\"age\":[39,42,31,35,74,61,32,62,33,53,41,36,40,24,32,40,61,42,31,28,26,45,28,44,28],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAKBRQAAAAAAAgFVAAAAAAADAUUAAAAAAAIBOQAAAAAAAAD9AAAAAAACAUEAAAAAAAEBQQAAAAAAAIFBAAAAAAABATkAAAAAAAEBSQAAAAAAAwFJAAAAAAADAU0AAAAAAAIBIQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBGQAAAAAAAoFZAAAAAAABAVEAAAAAAAABZQAAAAAAAgFRAAAAAAAAAWUAAAAAAAMBQQAAAAAAAwFVAAAAAAAAAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAMBLQAAAAAAAgFZAAAAAAAAA+H8AAAAAAIBIQAAAAAAAgE9AAAAAAABATEAAAAAAAIBCQAAAAAAAIFNAAAAAAAAA+H8AAAAAAMBOQAAAAAAA4FJAAAAAAABAVkAAAAAAAABJQAAAAAAAQFRAAAAAAAAATEAAAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8AAAAAAAD4fwAAAAAAQFNAAAAAAAAA+H8AAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect reject\":{\"__ndarray__\":\"AAAAAADgVEAAAAAAAABJQAAAAAAAQFRAAAAAAAAAVEAAAAAAAIBIQAAAAAAAIFJAAAAAAABAUEAAAAAAAGBUQAAAAAAAAPh/AAAAAABAUEAAAAAAAEBRQAAAAAAAAPh/AAAAAABATUAAAAAAAABRQAAAAAAAgFVAAAAAAAAA+H8AAAAAAEBSQAAAAAAAwEVAAAAAAAAATkAAAAAAAABZQAAAAAAA4FBAAAAAAAAAWUAAAAAAAABOQAAAAAAAQFNAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAMBSQAAAAAAAQFZAAAAAAAAAVkAAAAAAAEBQQAAAAAAAIFBAAAAAAACAUEAAAAAAAABPQAAAAAAAAFFAAAAAAADAUUAAAAAAAIBUQAAAAAAAAFNAAAAAAADgU0AAAAAAAIBLQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBLQAAAAAAAIFZAAAAAAADgVUAAAAAAAABZQAAAAAAAQFNAAAAAAAAAWUAAAAAAAABUQAAAAAAAYFFAAAAAAABAVEA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct hit\":{\"__ndarray__\":\"AAAAAADAVkAAAAAAAOBSQAAAAAAAYFZAAAAAAABgVkAAAAAAACBRQAAAAAAAwFFAAAAAAADAUEAAAAAAAABLQAAAAAAAoFFAAAAAAACgUkAAAAAAAIBUQAAAAAAAIFNAAAAAAAAAVEAAAAAAAABNQAAAAAAAQFVAAAAAAABAUUAAAAAAAGBRQAAAAAAAwFVAAAAAAAAAV0AAAAAAAABZQAAAAAAAgFFAAAAAAAAAWUAAAAAAAGBWQAAAAAAAAE9AAAAAAADAVUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAABJQAAAAAAAAFZAAAAAAAAAVEAAAAAAAIBIQAAAAAAAoFFAAAAAAAAAUEAAAAAAAIBOQAAAAAAAIFNAAAAAAABAUEAAAAAAAABQQAAAAAAA4FJAAAAAAACAT0AAAAAAAIBNQAAAAAAA4FRAAAAAAAAATEAAAAAAAEBSQAAAAAAAAFBAAAAAAAAATkAAAAAAAABZQAAAAAAAoFFAAAAAAAAAWUAAAAAAAABOQAAAAAAAYFJAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"correct hit percentage\":[65,90,90,100,60,80,90,45,80,100,70,90,95,85,75,40,100,70,100,100,60,100,100,65,100],\"correct reject percentage\":[80,90,95,75,65,20,75,90,100,50,55,100,65,75,55,100,40,90,70,50,80,95,75,25,40],\"ess\":[2,7,3,20,12,2,3,9,10,7,19,0,8,4,7,14,12,10,11,12,1,6,4,6,2],\"gender\":[\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],\"insomnia\":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],\"participant number\":[8,16,18,22,27,28,30,33,34,35,38,41,46,49,55,71,76,77,78,80,89,90,93,100,101],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAIBWQAAAAAAAIFdAAAAAAADgVUAAAAAAAEBPQAAAAAAAAElAAAAAAACgVEAAAAAAAOBQQAAAAAAAgFZAAAAAAADAUkAAAAAAAEBPQAAAAAAAwFdAAAAAAAAAVEAAAAAAAABUQAAAAAAAQFBAAAAAAACAUUAAAAAAAIBRQAAAAAAAAFRAAAAAAABAVUAAAAAAAMBSQAAAAAAAgFFAAAAAAABgWEAAAAAAAOBVQAAAAAAAgEZAAAAAAACAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"psqi\":[13,11,9,8,9,14,9,9,12,8,5,7,12,13,13,11,4,10,6,7,8,9,7,15,7],\"sci\":[9,4,10,13,13,15,16,14,14,14,14,15,10,14,5,0,16,11,14,12,14,14,16,1,14]},\"selected\":{\"id\":\"1157\"},\"selection_policy\":{\"id\":\"1158\"}},\"id\":\"1143\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1129\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"1126\"}},\"id\":\"1131\",\"type\":\"CDSView\"},{\"attributes\":{\"items\":[{\"id\":\"1142\"},{\"id\":\"1160\"}]},\"id\":\"1141\",\"type\":\"Legend\"},{\"attributes\":{\"data_source\":{\"id\":\"1126\"},\"glyph\":{\"id\":\"1128\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1129\"},\"selection_glyph\":null,\"view\":{\"id\":\"1131\"}},\"id\":\"1130\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1157\",\"type\":\"Selection\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1128\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1135\",\"type\":\"BasicTickFormatter\"}],\"root_ids\":[\"1095\"]},\"title\":\"Bokeh Application\",\"version\":\"2.2.1\"}};\n", " var render_items = [{\"docid\":\"d9beea30-7767-4a3f-906b-26c6f667282f\",\"root_ids\":[\"1095\"],\"roots\":{\"1095\":\"a16d6326-fc7a-4529-86a5-29344a7bc1d8\"}}];\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", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1095" } }, "output_type": "display_data" } ], "source": [ "# For convenience\n", "x = \"confidence when correct\"\n", "y = \"confidence when incorrect\"\n", "\n", "# Make figure\n", "p = bokeh.plotting.figure(\n", " width=400, \n", " height=300, \n", " x_axis_label=x, \n", " y_axis_label=y,\n", ")\n", "\n", "# Add glyphs\n", "p.circle(\n", " source=df.loc[~df[\"insomnia\"], :], \n", " x=x, \n", " y=y, \n", " legend_label=\"normal sleepers\",\n", ")\n", "\n", "p.circle(\n", " source=df.loc[df[\"insomnia\"], :],\n", " x=x,\n", " y=y,\n", " color=\"orange\",\n", " legend_label=\"insomniacs\",\n", ")\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We got the plot we wanted, but the legend is clashing with the data. Fortunately, Bokeh allows us to set attributes of the figure whenever we like. We can therefore set the legend position to be in the upper left corner. We will also set the `click_policy` for the legend to be `'hide'`, which will hide glyphs if you click the legend, which can be convenient for viewing cluttered plots (though this one is not cluttered, really)." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "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 = {\"2e808d1d-1094-440d-9f0a-9f3b373c2b1c\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1104\"}],\"center\":[{\"id\":\"1107\"},{\"id\":\"1111\"},{\"id\":\"1141\"}],\"left\":[{\"id\":\"1108\"}],\"plot_height\":300,\"plot_width\":400,\"renderers\":[{\"id\":\"1130\"},{\"id\":\"1147\"}],\"title\":{\"id\":\"1133\"},\"toolbar\":{\"id\":\"1119\"},\"x_range\":{\"id\":\"1096\"},\"x_scale\":{\"id\":\"1100\"},\"y_range\":{\"id\":\"1098\"},\"y_scale\":{\"id\":\"1102\"}},\"id\":\"1095\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{},\"id\":\"1158\",\"type\":\"UnionRenderers\"},{\"attributes\":{},\"id\":\"1137\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{},\"id\":\"1138\",\"type\":\"Selection\"},{\"attributes\":{\"label\":{\"value\":\"normal sleepers\"},\"renderers\":[{\"id\":\"1130\"}]},\"id\":\"1142\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1139\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"source\":{\"id\":\"1143\"}},\"id\":\"1148\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"orange\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1146\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1096\",\"type\":\"DataRange1d\"},{\"attributes\":{\"data_source\":{\"id\":\"1143\"},\"glyph\":{\"id\":\"1145\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1146\"},\"selection_glyph\":null,\"view\":{\"id\":\"1148\"}},\"id\":\"1147\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"axis_label\":\"confidence when incorrect\",\"formatter\":{\"id\":\"1135\"},\"ticker\":{\"id\":\"1109\"}},\"id\":\"1108\",\"type\":\"LinearAxis\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1118\",\"type\":\"BoxAnnotation\"},{\"attributes\":{\"data\":{\"age\":[42,45,16,21,18,28,38,17,25,22,41,53,43,23,19,45,43,35,24,64,36,35,43,44,29,22,46,35,53,29,31,21,42,23,54,24,21,21,43,50,53,16,67,36,34,42,46,69,31,44,25,45,47,33,18,74,21,45,37,41,41,34,39,18,31,26,66,62,22,41,46,56,23,70,24,40,33],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAACARUAAAAAAAABUQAAAAAAAAEtAAAAAAAAASUAAAAAAAABUQAAAAAAAgFdAAAAAAADAU0AAAAAAACBTQAAAAAAAQFVAAAAAAACAUUAAAAAAAOBQQAAAAAAAAExAAAAAAACASEAAAAAAAKBRQAAAAAAAgFBAAAAAAACATkAAAAAAAABQQAAAAAAAoFJAAAAAAAAAVEAAAAAAAIBQQAAAAAAAgFBAAAAAAAAAM0AAAAAAAIB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IBSQAAAAAAAQFBAAAAAAABAVEAAAAAAAEBUQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"confidence when correct hit\":{\"__ndarray__\":\"AAAAAADASUAAAAAAAMBSQAAAAAAAgFFAAAAAAADAT0AAAAAAACBTQAAAAAAAAFlAAAAAAABAU0AAAAAAACBUQAAAAAAAgFZAAAAAAACAUUAAAAAAACBTQAAAAAAAAERAAAAAAAAASkAAAAAAAABWQAAAAAAAAE9AAAAAAAAAUUAAAAAAAIBNQAAAAAAA4FJAAAAAAAAAUUAAAAAAAABJQAAAAAAAAFZAAAAAAACAPUAAAAAAAGBQQAAAAAAAwFRAAAAAAADAUEAAAAAAAIBTQAAAAAAAIFJAAAAAAABAT0AAAAAAAABLQAAAAAAAwFJAAAAAAACAVEAAAAAAAIBQQAAAAAAAwFRAAAAAAADAUEAAAAAAAIBWQAAAAAAAQFhAAAAAAABAUEAAAAAAAABVQAAAAAAAgFJAAAAAAAAgV0AAAAAAAABVQAAAAAAAgEtAAAAAAACAUUAAAAAAAOBQQAAAAAAAQE1AAAAAAACgUkAAAAAAAABXQAAAAAAAAFRAAAAAAACAWEAAAAAAAMBVQAAAAAAAwE5AAAAAAAAgVEAAAAAAAABZQAAAAAAAgFFAAAAAAADgUEAAAAAAAIBQQAAAAAAAoFZAAAAAAACAUkAAAAAAAOBXQAAAAAAAAFRAAAAAAACgV0AAAAAAAEBUQAAAAAAAgExAAAAAAABAV0AAAAAAAABZQAAAAAAAQFVAAAAAAADgUEAAAAAAAEBUQAAAAAAAgFBAAAAAAACAS0AAAAAAAIBWQAAAAAAAgE9AAAAAAABAU0AAAAAAAGBQQAAAAAAAwE5AAAAAAACASkAAAAAAAABUQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACASEAAAAAAAMBQQAAAAAAAQEtAAAAAAAAASUAAAAAAAMBUQAAAAAAAQFBAAAAAAAAAQkAAAAAAAOBQQAAAAAAAAPh/AAAAAACAUUAAAAAAAMBLQAAAAAAAAEZAAAAAAAAAPUAAAAAAAEBLQAAAAAAAAElAAAAAAAAAS0AAAAAAAIBMQAAAAAAAwEFAAAAAAADAUEAAAAAAAIA4QAAAAAAAwE9AAAAAAACAQUAAAAAAAIBGQAAAAAAAAEtAAAAAAACASkAAAAAAAABVQAAAAAAAwFZAAAAAAAAAP0AAAAAAAIBJQAAAAAAAgEVAAAAAAACASEAAAAAAAAA9QAAAAAAAAFNAAAAAAAAAREAAAAAAAMBTQAAAAAAAwEtAAAAAAAAAUUAAAAAAAEBQQAAAAAAAAFFAAAAAAABAUEAAAAAAAABNQAAAAAAAgEFAAAAAAADATUAAAAAAAABJQAAAAAAAwEdAAAAAAAAA+H8AAAAAAGBSQAAAAAAAgFFAAAAAAAAAREAAAAAAAMBQQAAAAAAAAPh/AAAAAADATkAAAAAAAMBUQAAAAAAAAERAAAAAAACASkAAAAAAAIBLQAAAAAAAQFRAAAAAAAAAUEAAAAAAAMBRQAAAAAAAgE1AAAAAAADAUEAAAAAAAABNQAAAAAAAAElAAAAAAADAVkAAAAAAAABJQAAAAAAAQFVAAAAAAAAAUEAAAAAAAIBUQAAAAAAAwE1AAAAAAAAATkAAAAAAAMBSQAAAAAAAwE1AAAAAAACAUkAAAAAAAABUQAAAAAAAQFRAAAAAAACASUAAAAAAAEBSQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"correct hit percentage\":[80,80,70,70,90,95,90,90,100,80,90,95,95,90,55,100,65,90,55,75,100,70,90,95,95,70,80,50,65,100,85,85,90,90,90,85,85,90,95,70,95,85,95,90,90,100,80,95,100,90,100,70,90,85,80,85,40,80,90,90,80,90,75,85,100,95,60,100,85,35,95,70,70,90,70,75,85],\"correct reject percentage\":[65,90,80,65,100,80,95,90,100,60,80,60,90,80,60,85,65,100,100,85,80,90,85,90,55,65,75,95,80,70,90,90,90,85,70,95,75,80,75,85,75,85,75,65,90,100,90,80,95,95,100,50,100,70,75,80,40,95,80,85,75,35,70,85,85,75,85,80,95,75,80,50,85,85,80,65,40],\"ess\":[5,1,3,4,5,12,4,4,11,6,3,11,10,12,6,13,12,5,10,4,4,6,3,0,12,6,5,9,7,6,10,18,11,8,16,7,9,11,4,7,4,11,12,3,3,4,11,1,4,2,9,1,2,12,6,5,5,4,9,3,8,6,10,21,5,5,9,1,8,11,5,7,10,7,15,7,7],\"gender\":[\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"m\",\"f\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\"],\"index\":[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],\"insomnia\":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],\"participant number\":[1,2,3,4,5,6,7,9,10,11,12,13,14,15,17,19,20,21,23,24,25,26,29,31,32,36,37,39,40,42,43,44,45,48,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,79,81,82,83,84,85,86,87,88,91,92,94,95,96,97,98,99,102,103],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAEBVQAAAAAAAwFJAAAAAAADgUEAAAAAAAMBXQAAAAAAA4FVAAAAAAAAgV0AAAAAAAIBWQAAAAAAAAFlAAAAAAACAUUAAAAAAAEBVQAAAAAAAYFNAAAAAAAAgV0AAAAAAAEBVQAAAAAAAwExAAAAAAAAgV0AAAAAAAEBQQAAAAAAAwFdAAAAAAABgU0AAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAOBVQAAAAAAAIFdAAAAAAADAUkAAAAAAAOBQQAAAAAAAYFNAAAAAAAAgUkAAAAAAACBSQAAAAAAAQFVAAAAAAADgVUAAAAAAAOBVQAAAAAAAgFZAAAAAAADgVUAAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAEBVQAAAAAAAQFVAAAAAAABgU0AAAAAAAEBVQAAAAAAAQFVAAAAAAABAVUAAAAAAAGBTQAAAAAAAgFZAAAAAAAAAWUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgWEAAAAAAACBXQAAAAAAAAFlAAAAAAAAATkAAAAAAAMBXQAAAAAAAYFNAAAAAAABgU0AAAAAAAKBUQAAAAAAAAERAAAAAAADgVUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgU0AAAAAAAEBPQAAAAAAAIFJAAAAAAABAVUAAAAAAACBXQAAAAAAAQFVAAAAAAAAgUkAAAAAAAIBWQAAAAAAAgFZAAAAAAACAS0AAAAAAAOBVQAAAAAAAAE5AAAAAAABgU0AAAAAAAOBVQAAAAAAAwFJAAAAAAACAUUAAAAAAAEBPQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"psqi\":[1,5,1,5,7,7,3,3,10,4,5,2,2,2,5,2,3,3,4,9,5,2,1,4,8,2,2,6,3,1,5,7,3,6,6,1,6,4,4,3,5,2,7,4,0,5,1,1,4,1,8,4,2,7,4,1,7,4,5,6,4,2,3,4,3,1,5,2,1,1,3,6,8,8,2,4,5],\"sci\":[29,19,23,26,21,19,28,29,17,22,28,31,31,32,25,30,28,30,22,20,26,32,32,24,26,30,28,21,29,32,26,26,23,18,22,29,20,27,19,29,24,29,17,26,30,17,25,31,27,32,28,25,30,21,29,20,22,23,20,17,27,27,22,25,30,32,30,32,28,31,29,26,20,19,31,22,24]},\"selected\":{\"id\":\"1138\"},\"selection_policy\":{\"id\":\"1139\"}},\"id\":\"1126\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"axis_label\":\"confidence when correct\",\"formatter\":{\"id\":\"1137\"},\"ticker\":{\"id\":\"1105\"}},\"id\":\"1104\",\"type\":\"LinearAxis\"},{\"attributes\":{},\"id\":\"1116\",\"type\":\"ResetTool\"},{\"attributes\":{},\"id\":\"1100\",\"type\":\"LinearScale\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1133\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1098\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1102\",\"type\":\"LinearScale\"},{\"attributes\":{},\"id\":\"1105\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1104\"},\"ticker\":null},\"id\":\"1107\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1113\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"axis\":{\"id\":\"1108\"},\"dimension\":1,\"ticker\":null},\"id\":\"1111\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1109\",\"type\":\"BasicTicker\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1112\"},{\"id\":\"1113\"},{\"id\":\"1114\"},{\"id\":\"1115\"},{\"id\":\"1116\"},{\"id\":\"1117\"}]},\"id\":\"1119\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1117\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1112\",\"type\":\"PanTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1118\"}},\"id\":\"1114\",\"type\":\"BoxZoomTool\"},{\"attributes\":{\"fill_color\":{\"value\":\"orange\"},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1145\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1115\",\"type\":\"SaveTool\"},{\"attributes\":{\"label\":{\"value\":\"insomniacs\"},\"renderers\":[{\"id\":\"1147\"}]},\"id\":\"1160\",\"type\":\"LegendItem\"},{\"attributes\":{\"data\":{\"age\":[39,42,31,35,74,61,32,62,33,53,41,36,40,24,32,40,61,42,31,28,26,45,28,44,28],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAKBRQAAAAAAAgFVAAAAAAADAUUAAAAAAAIBOQAAAAAAAAD9AAAAAAACAUEAAAAAAAEBQQAAAAAAAIFBAAAAAAABATkAAAAAAAEBSQAAAAAAAwFJAAAAAAADAU0AAAAAAAIBIQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBGQAAAAAAAoFZAAAAAAABAVEAAAAAAAABZQAAAAAAAgFRAAAAAAAAAWUAAAAAAAMBQQAAAAAAAwFVAAAAAAAAAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAMBLQAAAAAAAgFZAAAAAAAAA+H8AAAAAAIBIQAAAAAAAgE9AAAAAAABATEAAAAAAAIBCQAAAAAAAIFNAAAAAAAAA+H8AAAAAAMBOQAAAAAAA4FJAAAAAAABAVkAAAAAAAABJQAAAAAAAQFRAAAAAAAAATEAAAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8AAAAAAAD4fwAAAAAAQFNAAAAAAAAA+H8AAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect reject\":{\"__ndarray__\":\"AAAAAADgVEAAAAAAAABJQAAAAAAAQFRAAAAAAAAAVEAAAAAAAIBIQAAAAAAAIFJAAAAAAABAUEAAAAAAAGBUQAAAAAAAAPh/AAAAAABAUEAAAAAAAEBRQAAAAAAAAPh/AAAAAABATUAAAAAAAABRQAAAAAAAgFVAAAAAAAAA+H8AAAAAAEBSQAAAAAAAwEVAAAAAAAAATkAAAAAAAABZQAAAAAAA4FBAAAAAAAAAWUAAAAAAAABOQAAAAAAAQFNAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAMBSQAAAAAAAQFZAAAAAAAAAVkAAAAAAAEBQQAAAAAAAIFBAAAAAAACAUEAAAAAAAABPQAAAAAAAAFFAAAAAAADAUUAAAAAAAIBUQAAAAAAAAFNAAAAAAADgU0AAAAAAAIBLQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBLQAAAAAAAIFZAAAAAAADgVUAAAAAAAABZQAAAAAAAQFNAAAAAAAAAWUAAAAAAAABUQAAAAAAAYFFAAAAAAABAVEA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct hit\":{\"__ndarray__\":\"AAAAAADAVkAAAAAAAOBSQAAAAAAAYFZAAAAAAABgVkAAAAAAACBRQAAAAAAAwFFAAAAAAADAUEAAAAAAAABLQAAAAAAAoFFAAAAAAACgUkAAAAAAAIBUQAAAAAAAIFNAAAAAAAAAVEAAAAAAAABNQAAAAAAAQFVAAAAAAABAUUAAAAAAAGBRQAAAAAAAwFVAAAAAAAAAV0AAAAAAAABZQAAAAAAAgFFAAAAAAAAAWUAAAAAAAGBWQAAAAAAAAE9AAAAAAADAVUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAABJQAAAAAAAAFZAAAAAAAAAVEAAAAAAAIBIQAAAAAAAoFFAAAAAAAAAUEAAAAAAAIBOQAAAAAAAIFNAAAAAAABAUEAAAAAAAABQQAAAAAAA4FJAAAAAAACAT0AAAAAAAIBNQAAAAAAA4FRAAAAAAAAATEAAAAAAAEBSQAAAAAAAAFBAAAAAAAAATkAAAAAAAABZQAAAAAAAoFFAAAAAAAAAWUAAAAAAAABOQAAAAAAAYFJAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"correct hit percentage\":[65,90,90,100,60,80,90,45,80,100,70,90,95,85,75,40,100,70,100,100,60,100,100,65,100],\"correct reject percentage\":[80,90,95,75,65,20,75,90,100,50,55,100,65,75,55,100,40,90,70,50,80,95,75,25,40],\"ess\":[2,7,3,20,12,2,3,9,10,7,19,0,8,4,7,14,12,10,11,12,1,6,4,6,2],\"gender\":[\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],\"insomnia\":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],\"participant number\":[8,16,18,22,27,28,30,33,34,35,38,41,46,49,55,71,76,77,78,80,89,90,93,100,101],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAIBWQAAAAAAAIFdAAAAAAADgVUAAAAAAAEBPQAAAAAAAAElAAAAAAACgVEAAAAAAAOBQQAAAAAAAgFZAAAAAAADAUkAAAAAAAEBPQAAAAAAAwFdAAAAAAAAAVEAAAAAAAABUQAAAAAAAQFBAAAAAAACAUUAAAAAAAIBRQAAAAAAAAFRAAAAAAABAVUAAAAAAAMBSQAAAAAAAgFFAAAAAAABgWEAAAAAAAOBVQAAAAAAAgEZAAAAAAACAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"psqi\":[13,11,9,8,9,14,9,9,12,8,5,7,12,13,13,11,4,10,6,7,8,9,7,15,7],\"sci\":[9,4,10,13,13,15,16,14,14,14,14,15,10,14,5,0,16,11,14,12,14,14,16,1,14]},\"selected\":{\"id\":\"1157\"},\"selection_policy\":{\"id\":\"1158\"}},\"id\":\"1143\",\"type\":\"ColumnDataSource\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1129\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"1126\"}},\"id\":\"1131\",\"type\":\"CDSView\"},{\"attributes\":{\"click_policy\":\"hide\",\"items\":[{\"id\":\"1142\"},{\"id\":\"1160\"}],\"location\":\"top_left\"},\"id\":\"1141\",\"type\":\"Legend\"},{\"attributes\":{\"data_source\":{\"id\":\"1126\"},\"glyph\":{\"id\":\"1128\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1129\"},\"selection_glyph\":null,\"view\":{\"id\":\"1131\"}},\"id\":\"1130\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1157\",\"type\":\"Selection\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1128\",\"type\":\"Circle\"},{\"attributes\":{},\"id\":\"1135\",\"type\":\"BasicTickFormatter\"}],\"root_ids\":[\"1095\"]},\"title\":\"Bokeh Application\",\"version\":\"2.2.1\"}};\n", " var render_items = [{\"docid\":\"2e808d1d-1094-440d-9f0a-9f3b373c2b1c\",\"root_ids\":[\"1095\"],\"roots\":{\"1095\":\"9947152e-e1b7-419f-b1a0-135f223cab23\"}}];\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", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1095" } }, "output_type": "display_data" } ], "source": [ "p.legend.location = \"top_left\"\n", "p.legend.click_policy = \"hide\"\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding tooltips\n", "\n", "Bokeh's interactivity is one of its greatest strengths. While we are plotting confidences when correct and incorrect, we have colored with insomniac status. We might also like to have access to other information in our (tidy) data source if we hover over a glyph. Let's say we want to know the participant number, gender, and age of each participant. We can tell Bokeh to give us this information by adding **tooltips** when we instantiate the figure.\n", "\n", "The syntax for a tooltip is a list of 2-tuples, where each tuple represents the tooltip you want. The first entry in the tuple is the label and the second is the column from the data source that has the values. The second entry must be preceded with an `@` symbol signifying that it is a field in the data source and not field that is intrinsic to the plot, which is preceded with a `$` sign. If there are spaces in the column heading, enclose the column name in braces. (See the [documentation for tooltip specification](https://bokeh.pydata.org/en/latest/docs/user_guide/tools.html#basic-tooltips) for more information.)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "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 = {\"13800512-a5d5-4e4c-aea9-0b43c82545a7\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1300\"}],\"center\":[{\"id\":\"1303\"},{\"id\":\"1307\"},{\"id\":\"1339\"}],\"left\":[{\"id\":\"1304\"}],\"plot_height\":300,\"plot_width\":400,\"renderers\":[{\"id\":\"1328\"},{\"id\":\"1345\"}],\"title\":{\"id\":\"1331\"},\"toolbar\":{\"id\":\"1316\"},\"x_range\":{\"id\":\"1292\"},\"x_scale\":{\"id\":\"1296\"},\"y_range\":{\"id\":\"1294\"},\"y_scale\":{\"id\":\"1298\"}},\"id\":\"1291\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"data_source\":{\"id\":\"1341\"},\"glyph\":{\"id\":\"1343\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1344\"},\"selection_glyph\":null,\"view\":{\"id\":\"1346\"}},\"id\":\"1345\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1292\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1336\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1333\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1314\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1337\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data\":{\"age\":[42,45,16,21,18,28,38,17,25,22,41,53,43,23,19,45,43,35,24,64,36,35,43,44,29,22,46,35,53,29,31,21,42,23,54,24,21,21,43,50,53,16,67,36,34,42,46,69,31,44,25,45,47,33,18,74,21,45,37,41,41,34,39,18,31,26,66,62,22,41,46,56,23,70,24,40,33],\"confidence correct reject\":{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AAEBUQAAAAAAAgFBAAAAAAACAS0AAAAAAAIBWQAAAAAAAgE9AAAAAAABAU0AAAAAAAGBQQAAAAAAAwE5AAAAAAACASkAAAAAAAABUQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACASEAAAAAAAMBQQAAAAAAAQEtAAAAAAAAASUAAAAAAAMBUQAAAAAAAQFBAAAAAAAAAQkAAAAAAAOBQQAAAAAAAAPh/AAAAAACAUUAAAAAAAMBLQAAAAAAAAEZAAAAAAAAAPUAAAAAAAEBLQAAAAAAAAElAAAAAAAAAS0AAAAAAAIBMQAAAAAAAwEFAAAAAAADAUEAAAAAAAIA4QAAAAAAAwE9AAAAAAACAQUAAAAAAAIBGQAAAAAAAAEtAAAAAAACASkAAAAAAAABVQAAAAAAAwFZAAAAAAAAAP0AAAAAAAIBJQAAAAAAAgEVAAAAAAACASEAAAAAAAAA9QAAAAAAAAFNAAAAAAAAAREAAAAAAAMBTQAAAAAAAwEtAAAAAAAAAUUAAAAAAAEBQQAAAAAAAAFFAAAAAAABAUEAAAAAAAABNQAAAAAAAgEFAAAAAAADATUAAAAAAAABJQAAAAAAAwEdAAAAAAAAA+H8AAAAAAGBSQAAAAAAAgFFAAAAAAAAAREAAAAAAAMBQQAAAAAAAAPh/AAAAAADATkAAAAAAAMBUQAAAAAAAAERAAAAAAACASkAAAAAAAIBLQAAAAAAAQFRAAAAAAAAAUEAAAAAAAMBRQAAAAAAAgE1AAAAAAADAUEAAAAAAAABNQAAAAAAAAElAAAAAAADAVkAAAAAAAABJQAAAAAAAQFVAAAAAAAAAUEAAAAAAAIBUQAAAAAAAwE1AAAAAAAAATkAAAAAAAMBSQAAAAAAAwE1AAAAAAACAUkAAAAAAAABUQAAAAAAAQFRAAAAAAACASUAAAAAAAEBSQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"correct hit percentage\":[80,80,70,70,90,95,90,90,100,80,90,95,95,90,55,100,65,90,55,75,100,70,90,95,95,70,80,50,65,100,85,85,90,90,90,85,85,90,95,70,95,85,95,90,90,100,80,95,100,90,100,70,90,85,80,85,40,80,90,90,80,90,75,85,100,95,60,100,85,35,95,70,70,90,70,75,85],\"correct reject percentage\":[65,90,80,65,100,80,95,90,100,60,80,60,90,80,60,85,65,100,100,85,80,90,85,90,55,65,75,95,80,70,90,90,90,85,70,95,75,80,75,85,75,85,75,65,90,100,90,80,95,95,100,50,100,70,75,80,40,95,80,85,75,35,70,85,85,75,85,80,95,75,80,50,85,85,80,65,40],\"ess\":[5,1,3,4,5,12,4,4,11,6,3,11,10,12,6,13,12,5,10,4,4,6,3,0,12,6,5,9,7,6,10,18,11,8,16,7,9,11,4,7,4,11,12,3,3,4,11,1,4,2,9,1,2,12,6,5,5,4,9,3,8,6,10,21,5,5,9,1,8,11,5,7,10,7,15,7,7],\"gender\":[\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"m\",\"f\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\"],\"index\":[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],\"insomnia\":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],\"participant number\":[1,2,3,4,5,6,7,9,10,11,12,13,14,15,17,19,20,21,23,24,25,26,29,31,32,36,37,39,40,42,43,44,45,48,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,79,81,82,83,84,85,86,87,88,91,92,94,95,96,97,98,99,102,103],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAEBVQAAAAAAAwFJAAAAAAADgUEAAAAAAAMBXQAAAAAAA4FVAAAAAAAAgV0AAAAAAAIBWQAAAAAAAAFlAAAAAAACAUUAAAAAAAEBVQAAAAAAAYFNAAAAAAAAgV0AAAAAAAEBVQAAAAAAAwExAAAAAAAAgV0AAAAAAAEBQQAAAAAAAwFdAAAAAAABgU0AAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAOBVQAAAAAAAIFdAAAAAAADAUkAAAAAAAOBQQAAAAAAAYFNAAAAAAAAgUkAAAAAAACBSQAAAAAAAQFVAAAAAAADgVUAAAAAAAOBVQAAAAAAAgFZAAAAAAADgVUAAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAEBVQAAAAAAAQFVAAAAAAABgU0AAAAAAAEBVQAAAAAAAQFVAAAAAAABAVUAAAAAAAGBTQAAAAAAAgFZAAAAAAAAAWUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgWEAAAAAAACBXQAAAAAAAAFlAAAAAAAAATkAAAAAAAMBXQAAAAAAAYFNAAAAAAABgU0AAAAAAAKBUQAAAAAAAAERAAAAAAADgVUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgU0AAAAAAAEBPQAAAAAAAIFJAAAAAAABAVUAAAAAAACBXQAAAAAAAQFVAAAAAAAAgUkAAAAAAAIBWQAAAAAAAgFZAAAAAAACAS0AAAAAAAOBVQAAAAAAAAE5AAAAAAABgU0AAAAAAAOBVQAAAAAAAwFJAAAAAAACAUUAAAAAAAEBPQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"psqi\":[1,5,1,5,7,7,3,3,10,4,5,2,2,2,5,2,3,3,4,9,5,2,1,4,8,2,2,6,3,1,5,7,3,6,6,1,6,4,4,3,5,2,7,4,0,5,1,1,4,1,8,4,2,7,4,1,7,4,5,6,4,2,3,4,3,1,5,2,1,1,3,6,8,8,2,4,5],\"sci\":[29,19,23,26,21,19,28,29,17,22,28,31,31,32,25,30,28,30,22,20,26,32,32,24,26,30,28,21,29,32,26,26,23,18,22,29,20,27,19,29,24,29,17,26,30,17,25,31,27,32,28,25,30,21,29,20,22,23,20,17,27,27,22,25,30,32,30,32,28,31,29,26,20,19,31,22,24]},\"selected\":{\"id\":\"1336\"},\"selection_policy\":{\"id\":\"1337\"}},\"id\":\"1324\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1296\",\"type\":\"LinearScale\"},{\"attributes\":{\"axis_label\":\"confidence when correct\",\"formatter\":{\"id\":\"1335\"},\"ticker\":{\"id\":\"1301\"}},\"id\":\"1300\",\"type\":\"LinearAxis\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1331\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1294\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1298\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"p-number\",\"@{participant number}\"],[\"gender\",\"@gender\"],[\"age\",\"@age\"]]},\"id\":\"1315\",\"type\":\"HoverTool\"},{\"attributes\":{\"label\":{\"value\":\"normal sleepers\"},\"renderers\":[{\"id\":\"1328\"}]},\"id\":\"1340\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1301\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1300\"},\"ticker\":null},\"id\":\"1303\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1309\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"axis_label\":\"confidence when incorrect\",\"formatter\":{\"id\":\"1333\"},\"ticker\":{\"id\":\"1305\"}},\"id\":\"1304\",\"type\":\"LinearAxis\"},{\"attributes\":{\"axis\":{\"id\":\"1304\"},\"dimension\":1,\"ticker\":null},\"id\":\"1307\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1305\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_color\":{\"value\":\"orange\"},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1343\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"insomniacs\"},\"renderers\":[{\"id\":\"1345\"}]},\"id\":\"1358\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1313\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1308\",\"type\":\"PanTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1314\"}},\"id\":\"1310\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1311\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1312\",\"type\":\"ResetTool\"},{\"attributes\":{\"data\":{\"age\":[39,42,31,35,74,61,32,62,33,53,41,36,40,24,32,40,61,42,31,28,26,45,28,44,28],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAKBRQAAAAAAAgFVAAAAAAADAUUAAAAAAAIBOQAAAAAAAAD9AAAAAAACAUEAAAAAAAEBQQAAAAAAAIFBAAAAAAABATkAAAAAAAEBSQAAAAAAAwFJAAAAAAADAU0AAAAAAAIBIQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBGQAAAAAAAoFZAAAAAAABAVEAAAAAAAABZQAAAAAAAgFRAAAAAAAAAWUAAAAAAAMBQQAAAAAAAwFVAAAAAAAAAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAMBLQAAAAAAAgFZAAAAAAAAA+H8AAAAAAIBIQAAAAAAAgE9AAAAAAABATEAAAAAAAIBCQAAAAAAAIFNAAAAAAAAA+H8AAAAAAMBOQAAAAAAA4FJAAAAAAABAVkAAAAAAAABJQAAAAAAAQFRAAAAAAAAATEAAAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8AAAAAAAD4fwAAAAAAQFNAAAAAAAAA+H8AAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect reject\":{\"__ndarray__\":\"AAAAAADgVEAAAAAAAABJQAAAAAAAQFRAAAAAAAAAVEAAAAAAAIBIQAAAAAAAIFJAAAAAAABAUEAAAAAAAGBUQAAAAAAAAPh/AAAAAABAUEAAAAAAAEBRQAAAAAAAAPh/AAAAAABATUAAAAAAAABRQAAAAAAAgFVAAAAAAAAA+H8AAAAAAEBSQAAAAAAAwEVAAAAAAAAATkAAAAAAAABZQAAAAAAA4FBAAAAAAAAAWUAAAAAAAABOQAAAAAAAQFNAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAMBSQAAAAAAAQFZAAAAAAAAAVkAAAAAAAEBQQAAAAAAAIFBAAAAAAACAUEAAAAAAAABPQAAAAAAAAFFAAAAAAADAUUAAAAAAAIBUQAAAAAAAAFNAAAAAAADgU0AAAAAAAIBLQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBLQAAAAAAAIFZAAAAAAADgVUAAAAAAAABZQAAAAAAAQFNAAAAAAAAAWUAAAAAAAABUQAAAAAAAYFFAAAAAAABAVEA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct hit\":{\"__ndarray__\":\"AAAAAADAVkAAAAAAAOBSQAAAAAAAYFZAAAAAAABgVkAAAAAAACBRQAAAAAAAwFFAAAAAAADAUEAAAAAAAABLQAAAAAAAoFFAAAAAAACgUkAAAAAAAIBUQAAAAAAAIFNAAAAAAAAAVEAAAAAAAABNQAAAAAAAQFVAAAAAAABAUUAAAAAAAGBRQAAAAAAAwFVAAAAAAAAAV0AAAAAAAABZQAAAAAAAgFFAAAAAAAAAWUAAAAAAAGBWQAAAAAAAAE9AAAAAAADAVUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAABJQAAAAAAAAFZAAAAAAAAAVEAAAAAAAIBIQAAAAAAAoFFAAAAAAAAAUEAAAAAAAIBOQAAAAAAAIFNAAAAAAABAUEAAAAAAAABQQAAAAAAA4FJAAAAAAACAT0AAAAAAAIBNQAAAAAAA4FRAAAAAAAAATEAAAAAAAEBSQAAAAAAAAFBAAAAAAAAATkAAAAAAAABZQAAAAAAAoFFAAAAAAAAAWUAAAAAAAABOQAAAAAAAYFJAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"correct hit percentage\":[65,90,90,100,60,80,90,45,80,100,70,90,95,85,75,40,100,70,100,100,60,100,100,65,100],\"correct reject percentage\":[80,90,95,75,65,20,75,90,100,50,55,100,65,75,55,100,40,90,70,50,80,95,75,25,40],\"ess\":[2,7,3,20,12,2,3,9,10,7,19,0,8,4,7,14,12,10,11,12,1,6,4,6,2],\"gender\":[\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],\"insomnia\":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],\"participant number\":[8,16,18,22,27,28,30,33,34,35,38,41,46,49,55,71,76,77,78,80,89,90,93,100,101],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAIBWQAAAAAAAIFdAAAAAAADgVUAAAAAAAEBPQAAAAAAAAElAAAAAAACgVEAAAAAAAOBQQAAAAAAAgFZAAAAAAADAUkAAAAAAAEBPQAAAAAAAwFdAAAAAAAAAVEAAAAAAAABUQAAAAAAAQFBAAAAAAACAUUAAAAAAAIBRQAAAAAAAAFRAAAAAAABAVUAAAAAAAMBSQAAAAAAAgFFAAAAAAABgWEAAAAAAAOBVQAAAAAAAgEZAAAAAAACAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"psqi\":[13,11,9,8,9,14,9,9,12,8,5,7,12,13,13,11,4,10,6,7,8,9,7,15,7],\"sci\":[9,4,10,13,13,15,16,14,14,14,14,15,10,14,5,0,16,11,14,12,14,14,16,1,14]},\"selected\":{\"id\":\"1355\"},\"selection_policy\":{\"id\":\"1356\"}},\"id\":\"1341\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1335\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1308\"},{\"id\":\"1309\"},{\"id\":\"1310\"},{\"id\":\"1311\"},{\"id\":\"1312\"},{\"id\":\"1313\"},{\"id\":\"1315\"}]},\"id\":\"1316\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1355\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1356\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data_source\":{\"id\":\"1324\"},\"glyph\":{\"id\":\"1326\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1327\"},\"selection_glyph\":null,\"view\":{\"id\":\"1329\"}},\"id\":\"1328\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1324\"}},\"id\":\"1329\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"orange\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1344\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"1341\"}},\"id\":\"1346\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1327\",\"type\":\"Circle\"},{\"attributes\":{\"click_policy\":\"hide\",\"items\":[{\"id\":\"1340\"},{\"id\":\"1358\"}],\"location\":\"top_left\"},\"id\":\"1339\",\"type\":\"Legend\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1326\",\"type\":\"Circle\"}],\"root_ids\":[\"1291\"]},\"title\":\"Bokeh Application\",\"version\":\"2.2.1\"}};\n", " var render_items = [{\"docid\":\"13800512-a5d5-4e4c-aea9-0b43c82545a7\",\"root_ids\":[\"1291\"],\"roots\":{\"1291\":\"e4de850b-70f2-4b67-b9e1-6276e68645a9\"}}];\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", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1291" } }, "output_type": "display_data" } ], "source": [ "# For convenience\n", "x = \"confidence when correct\"\n", "y = \"confidence when incorrect\"\n", "\n", "# Make figure\n", "p = bokeh.plotting.figure(\n", " width=400,\n", " height=300,\n", " x_axis_label=x,\n", " y_axis_label=y,\n", " tooltips=[\n", " (\"p-number\", \"@{participant number}\"),\n", " (\"gender\", \"@gender\"),\n", " (\"age\", \"@age\"),\n", " ],\n", ")\n", "\n", "# Add glyphs\n", "p.circle(\n", " source=df.loc[~df[\"insomnia\"], :], \n", " x=x, \n", " y=y, \n", " legend_label=\"normal sleepers\",\n", ")\n", "\n", "p.circle(\n", " source=df.loc[df[\"insomnia\"], :],\n", " x=x,\n", " y=y,\n", " color=\"orange\",\n", " legend_label=\"insomniacs\",\n", ")\n", "\n", "p.legend.location = \"top_left\"\n", "p.legend.click_policy = \"hide\"\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Saving Bokeh plots\n", "\n", "*Note that saving Bokeh plots as presented below will now work in Google Colab.*\n", "\n", "After you create your plot, you can save it to a variety of formats. Most commonly you would save them as PNG (for presentations), SVG (for publications in the paper of the past), and HTML (for the paper of the future or sharing with colleagues). \n", "\n", "To save as a PNG for quick use, you can click the disk icon in the tool bar. \n", "\n", "To save to SVG, you first change the output backend to `\"svg\"` and then you can click the disk icon again, and you will get an SVG rendering of the plot. For it to work, though, you will need to have Google Chrome installed on your machine along with [chromedriver](https://chromedriver.chromium.org). \n", "\n", "After saving the SVG, you should change the output backend back to `\"canvas\"` because it has much better in-browser performance." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "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 = {\"779c2c5b-312e-4557-b82d-0e249700ada6\":{\"roots\":{\"references\":[{\"attributes\":{\"below\":[{\"id\":\"1300\"}],\"center\":[{\"id\":\"1303\"},{\"id\":\"1307\"},{\"id\":\"1339\"}],\"left\":[{\"id\":\"1304\"}],\"output_backend\":\"svg\",\"plot_height\":300,\"plot_width\":400,\"renderers\":[{\"id\":\"1328\"},{\"id\":\"1345\"}],\"title\":{\"id\":\"1331\"},\"toolbar\":{\"id\":\"1316\"},\"x_range\":{\"id\":\"1292\"},\"x_scale\":{\"id\":\"1296\"},\"y_range\":{\"id\":\"1294\"},\"y_scale\":{\"id\":\"1298\"}},\"id\":\"1291\",\"subtype\":\"Figure\",\"type\":\"Plot\"},{\"attributes\":{\"data_source\":{\"id\":\"1341\"},\"glyph\":{\"id\":\"1343\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1344\"},\"selection_glyph\":null,\"view\":{\"id\":\"1346\"}},\"id\":\"1345\",\"type\":\"GlyphRenderer\"},{\"attributes\":{},\"id\":\"1292\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1336\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1333\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"bottom_units\":\"screen\",\"fill_alpha\":0.5,\"fill_color\":\"lightgrey\",\"left_units\":\"screen\",\"level\":\"overlay\",\"line_alpha\":1.0,\"line_color\":\"black\",\"line_dash\":[4,4],\"line_width\":2,\"right_units\":\"screen\",\"top_units\":\"screen\"},\"id\":\"1314\",\"type\":\"BoxAnnotation\"},{\"attributes\":{},\"id\":\"1337\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data\":{\"age\":[42,45,16,21,18,28,38,17,25,22,41,53,43,23,19,45,43,35,24,64,36,35,43,44,29,22,46,35,53,29,31,21,42,23,54,24,21,21,43,50,53,16,67,36,34,42,46,69,31,44,25,45,47,33,18,74,21,45,37,41,41,34,39,18,31,26,66,62,22,41,46,56,23,70,24,40,33],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAACARUAAAAAAAABUQAAAAAAAAEtAAAAAAAAASUAAAAAAAABUQAAAAAAAgFdAAAAAAADAU0AAAAAAACBTQAAAAAAAQFVAAAAAAACAUUAAAAAAAOBQQAAAAAAAAExAAAAAAACASEAAAAAAAKBRQAAAAAAAgFBAAAAAAACATkAAAAAAAABQQAAAAAAAoFJAAAAAAAAAVEAAAAAAAIBQQAAAAAAAgFBAAAAAAAAAM0AAAAAAAIBEQAAAAAAAwFNAAAAAAABAUEAAAAAAAEBTQAAAAAAAAFlAAAAAAABAU0AAAAAAAMBHQAAAAAAAIFBAAAAAAABAVEAAAAAAAIBRQAAAAAAAIFRAAAAAAABAUUAAAAAAAGBTQAAAAAAAgFJAAAAAAAAATEAAAAAAAGBSQAAAAAAAAFFAAAAAAADAV0AAAAAAAABRQAAAAAAAAElAAAAAAABAUUAAAAAAAIBLQAAAAAAAYFJAAAAAAACAUkAAAAAAAABXQAAAAAAAoFNAAAAAAACAVkAAAAAAAEBRQAAAAAAAQE1AAAAAAACAT0AAAAAAAOBRQAAAAAAAQE1AAAAAAACAUEAAAAAAAIBPQAAAAAAAoFJAAAAAAAAAU0AAAAAAAOBUQAAAAAAAgFFAAAAAAACAVUAAAAAAAMBRQAAAAAAAwE1AAAAAAADAVkAAAAAAAABZQAAAAAAAgFRAAAAAAACAUkAAAAAAAKBSQAAAAAAAAFJAAAAAAAAAVEAAAAAAAABUQAAAAAAA4FBAAAAAAABAU0AAAAAAAMBVQAAAAAAAgFFAAAAAAAAAVUAAAAAAAAA/QA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAABARkAAAAAAAMBLQAAAAAAAgExAAAAAAAAAUEAAAAAAAMBUQAAAAAAAQ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AAAQFRAAAAAAACASUAAAAAAAEBSQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"correct hit percentage\":[80,80,70,70,90,95,90,90,100,80,90,95,95,90,55,100,65,90,55,75,100,70,90,95,95,70,80,50,65,100,85,85,90,90,90,85,85,90,95,70,95,85,95,90,90,100,80,95,100,90,100,70,90,85,80,85,40,80,90,90,80,90,75,85,100,95,60,100,85,35,95,70,70,90,70,75,85],\"correct reject percentage\":[65,90,80,65,100,80,95,90,100,60,80,60,90,80,60,85,65,100,100,85,80,90,85,90,55,65,75,95,80,70,90,90,90,85,70,95,75,80,75,85,75,85,75,65,90,100,90,80,95,95,100,50,100,70,75,80,40,95,80,85,75,35,70,85,85,75,85,80,95,75,80,50,85,85,80,65,40],\"ess\":[5,1,3,4,5,12,4,4,11,6,3,11,10,12,6,13,12,5,10,4,4,6,3,0,12,6,5,9,7,6,10,18,11,8,16,7,9,11,4,7,4,11,12,3,3,4,11,1,4,2,9,1,2,12,6,5,5,4,9,3,8,6,10,21,5,5,9,1,8,11,5,7,10,7,15,7,7],\"gender\":[\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"m\",\"f\",\"m\",\"f\",\"m\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"f\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\"],\"index\":[25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],\"insomnia\":[false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false],\"participant number\":[1,2,3,4,5,6,7,9,10,11,12,13,14,15,17,19,20,21,23,24,25,26,29,31,32,36,37,39,40,42,43,44,45,48,50,51,52,53,54,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,79,81,82,83,84,85,86,87,88,91,92,94,95,96,97,98,99,102,103],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAEBVQAAAAAAAwFJAAAAAAADgUEAAAAAAAMBXQAAAAAAA4FVAAAAAAAAgV0AAAAAAAIBWQAAAAAAAAFlAAAAAAACAUUAAAAAAAEBVQAAAAAAAYFNAAAAAAAAgV0AAAAAAAEBVQAAAAAAAwExAAAAAAAAgV0AAAAAAAEBQQAAAAAAAwFdAAAAAAABgU0AAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAOBVQAAAAAAAIFdAAAAAAADAUkAAAAAAAOBQQAAAAAAAYFNAAAAAAAAgUkAAAAAAACBSQAAAAAAAQFVAAAAAAADgVUAAAAAAAOBVQAAAAAAAgFZAAAAAAADgVUAAAAAAAABUQAAAAAAAgFZAAAAAAAAAVEAAAAAAAEBVQAAAAAAAQFVAAAAAAABgU0AAAAAAAEBVQAAAAAAAQFVAAAAAAABAVUAAAAAAAGBTQAAAAAAAgFZAAAAAAAAAWUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgWEAAAAAAACBXQAAAAAAAAFlAAAAAAAAATkAAAAAAAMBXQAAAAAAAYFNAAAAAAABgU0AAAAAAAKBUQAAAAAAAAERAAAAAAADgVUAAAAAAAEBVQAAAAAAA4FVAAAAAAABgU0AAAAAAAEBPQAAAAAAAIFJAAAAAAABAVUAAAAAAACBXQAAAAAAAQFVAAAAAAAAgUkAAAAAAAIBWQAAAAAAAgFZAAAAAAACAS0AAAAAAAOBVQAAAAAAAAE5AAAAAAABgU0AAAAAAAOBVQAAAAAAAwFJAAAAAAACAUUAAAAAAAEBPQA==\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[77]},\"psqi\":[1,5,1,5,7,7,3,3,10,4,5,2,2,2,5,2,3,3,4,9,5,2,1,4,8,2,2,6,3,1,5,7,3,6,6,1,6,4,4,3,5,2,7,4,0,5,1,1,4,1,8,4,2,7,4,1,7,4,5,6,4,2,3,4,3,1,5,2,1,1,3,6,8,8,2,4,5],\"sci\":[29,19,23,26,21,19,28,29,17,22,28,31,31,32,25,30,28,30,22,20,26,32,32,24,26,30,28,21,29,32,26,26,23,18,22,29,20,27,19,29,24,29,17,26,30,17,25,31,27,32,28,25,30,21,29,20,22,23,20,17,27,27,22,25,30,32,30,32,28,31,29,26,20,19,31,22,24]},\"selected\":{\"id\":\"1336\"},\"selection_policy\":{\"id\":\"1337\"}},\"id\":\"1324\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1296\",\"type\":\"LinearScale\"},{\"attributes\":{\"axis_label\":\"confidence when correct\",\"formatter\":{\"id\":\"1335\"},\"ticker\":{\"id\":\"1301\"}},\"id\":\"1300\",\"type\":\"LinearAxis\"},{\"attributes\":{\"text\":\"\"},\"id\":\"1331\",\"type\":\"Title\"},{\"attributes\":{},\"id\":\"1294\",\"type\":\"DataRange1d\"},{\"attributes\":{},\"id\":\"1298\",\"type\":\"LinearScale\"},{\"attributes\":{\"callback\":null,\"tooltips\":[[\"p-number\",\"@{participant number}\"],[\"gender\",\"@gender\"],[\"age\",\"@age\"]]},\"id\":\"1315\",\"type\":\"HoverTool\"},{\"attributes\":{\"label\":{\"value\":\"normal sleepers\"},\"renderers\":[{\"id\":\"1328\"}]},\"id\":\"1340\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1301\",\"type\":\"BasicTicker\"},{\"attributes\":{\"axis\":{\"id\":\"1300\"},\"ticker\":null},\"id\":\"1303\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1309\",\"type\":\"WheelZoomTool\"},{\"attributes\":{\"axis_label\":\"confidence when incorrect\",\"formatter\":{\"id\":\"1333\"},\"ticker\":{\"id\":\"1305\"}},\"id\":\"1304\",\"type\":\"LinearAxis\"},{\"attributes\":{\"axis\":{\"id\":\"1304\"},\"dimension\":1,\"ticker\":null},\"id\":\"1307\",\"type\":\"Grid\"},{\"attributes\":{},\"id\":\"1305\",\"type\":\"BasicTicker\"},{\"attributes\":{\"fill_color\":{\"value\":\"orange\"},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1343\",\"type\":\"Circle\"},{\"attributes\":{\"label\":{\"value\":\"insomniacs\"},\"renderers\":[{\"id\":\"1345\"}]},\"id\":\"1358\",\"type\":\"LegendItem\"},{\"attributes\":{},\"id\":\"1313\",\"type\":\"HelpTool\"},{\"attributes\":{},\"id\":\"1308\",\"type\":\"PanTool\"},{\"attributes\":{\"overlay\":{\"id\":\"1314\"}},\"id\":\"1310\",\"type\":\"BoxZoomTool\"},{\"attributes\":{},\"id\":\"1311\",\"type\":\"SaveTool\"},{\"attributes\":{},\"id\":\"1312\",\"type\":\"ResetTool\"},{\"attributes\":{\"data\":{\"age\":[39,42,31,35,74,61,32,62,33,53,41,36,40,24,32,40,61,42,31,28,26,45,28,44,28],\"confidence correct reject\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAKBRQAAAAAAAgFVAAAAAAADAUUAAAAAAAIBOQAAAAAAAAD9AAAAAAACAUEAAAAAAAEBQQAAAAAAAIFBAAAAAAABATkAAAAAAAEBSQAAAAAAAwFJAAAAAAADAU0AAAAAAAIBIQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBGQAAAAAAAoFZAAAAAAABAVEAAAAAAAABZQAAAAAAAgFRAAAAAAAAAWUAAAAAAAMBQQAAAAAAAwFVAAAAAAAAAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect hit\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAMBLQAAAAAAAgFZAAAAAAAAA+H8AAAAAAIBIQAAAAAAAgE9AAAAAAABATEAAAAAAAIBCQAAAAAAAIFNAAAAAAAAA+H8AAAAAAMBOQAAAAAAA4FJAAAAAAABAVkAAAAAAAABJQAAAAAAAQFRAAAAAAAAATEAAAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8AAAAAAAD4fwAAAAAAQFNAAAAAAAAA+H8AAAAAAAD4fwAAAAAAAFJAAAAAAAAA+H8=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence incorrect reject\":{\"__ndarray__\":\"AAAAAADgVEAAAAAAAABJQAAAAAAAQFRAAAAAAAAAVEAAAAAAAIBIQAAAAAAAIFJAAAAAAABAUEAAAAAAAGBUQAAAAAAAAPh/AAAAAABAUEAAAAAAAEBRQAAAAAAAAPh/AAAAAABATUAAAAAAAABRQAAAAAAAgFVAAAAAAAAA+H8AAAAAAEBSQAAAAAAAwEVAAAAAAAAATkAAAAAAAABZQAAAAAAA4FBAAAAAAAAAWUAAAAAAAABOQAAAAAAAQFNAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct\":{\"__ndarray__\":\"AAAAAABAV0AAAAAAAMBSQAAAAAAAQFZAAAAAAAAAVkAAAAAAAEBQQAAAAAAAIFBAAAAAAACAUEAAAAAAAABPQAAAAAAAAFFAAAAAAADAUUAAAAAAAIBUQAAAAAAAAFNAAAAAAADgU0AAAAAAAIBLQAAAAAAAQFVAAAAAAACAUUAAAAAAAEBLQAAAAAAAIFZAAAAAAADgVUAAAAAAAABZQAAAAAAAQFNAAAAAAAAAWUAAAAAAAABUQAAAAAAAYFFAAAAAAABAVEA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when correct hit\":{\"__ndarray__\":\"AAAAAADAVkAAAAAAAOBSQAAAAAAAYFZAAAAAAABgVkAAAAAAACBRQAAAAAAAwFFAAAAAAADAUEAAAAAAAABLQAAAAAAAoFFAAAAAAACgUkAAAAAAAIBUQAAAAAAAIFNAAAAAAAAAVEAAAAAAAABNQAAAAAAAQFVAAAAAAABAUUAAAAAAAGBRQAAAAAAAwFVAAAAAAAAAV0AAAAAAAABZQAAAAAAAgFFAAAAAAAAAWUAAAAAAAGBWQAAAAAAAAE9AAAAAAADAVUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"confidence when incorrect\":{\"__ndarray__\":\"AAAAAACAVkAAAAAAAABJQAAAAAAAAFZAAAAAAAAAVEAAAAAAAIBIQAAAAAAAoFFAAAAAAAAAUEAAAAAAAIBOQAAAAAAAIFNAAAAAAABAUEAAAAAAAABQQAAAAAAA4FJAAAAAAACAT0AAAAAAAIBNQAAAAAAA4FRAAAAAAAAATEAAAAAAAEBSQAAAAAAAAFBAAAAAAAAATkAAAAAAAABZQAAAAAAAoFFAAAAAAAAAWUAAAAAAAABOQAAAAAAAYFJAAAAAAAAAS0A=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"correct hit percentage\":[65,90,90,100,60,80,90,45,80,100,70,90,95,85,75,40,100,70,100,100,60,100,100,65,100],\"correct reject percentage\":[80,90,95,75,65,20,75,90,100,50,55,100,65,75,55,100,40,90,70,50,80,95,75,25,40],\"ess\":[2,7,3,20,12,2,3,9,10,7,19,0,8,4,7,14,12,10,11,12,1,6,4,6,2],\"gender\":[\"f\",\"m\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"f\",\"m\",\"m\",\"f\",\"m\",\"f\",\"f\",\"f\"],\"index\":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24],\"insomnia\":[true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],\"participant number\":[8,16,18,22,27,28,30,33,34,35,38,41,46,49,55,71,76,77,78,80,89,90,93,100,101],\"percent correct\":{\"__ndarray__\":\"AAAAAAAgUkAAAAAAAIBWQAAAAAAAIFdAAAAAAADgVUAAAAAAAEBPQAAAAAAAAElAAAAAAACgVEAAAAAAAOBQQAAAAAAAgFZAAAAAAADAUkAAAAAAAEBPQAAAAAAAwFdAAAAAAAAAVEAAAAAAAABUQAAAAAAAQFBAAAAAAACAUUAAAAAAAIBRQAAAAAAAAFRAAAAAAABAVUAAAAAAAMBSQAAAAAAAgFFAAAAAAABgWEAAAAAAAOBVQAAAAAAAgEZAAAAAAACAUUA=\",\"dtype\":\"float64\",\"order\":\"little\",\"shape\":[25]},\"psqi\":[13,11,9,8,9,14,9,9,12,8,5,7,12,13,13,11,4,10,6,7,8,9,7,15,7],\"sci\":[9,4,10,13,13,15,16,14,14,14,14,15,10,14,5,0,16,11,14,12,14,14,16,1,14]},\"selected\":{\"id\":\"1355\"},\"selection_policy\":{\"id\":\"1356\"}},\"id\":\"1341\",\"type\":\"ColumnDataSource\"},{\"attributes\":{},\"id\":\"1335\",\"type\":\"BasicTickFormatter\"},{\"attributes\":{\"active_drag\":\"auto\",\"active_inspect\":\"auto\",\"active_multi\":null,\"active_scroll\":\"auto\",\"active_tap\":\"auto\",\"tools\":[{\"id\":\"1308\"},{\"id\":\"1309\"},{\"id\":\"1310\"},{\"id\":\"1311\"},{\"id\":\"1312\"},{\"id\":\"1313\"},{\"id\":\"1315\"}]},\"id\":\"1316\",\"type\":\"Toolbar\"},{\"attributes\":{},\"id\":\"1355\",\"type\":\"Selection\"},{\"attributes\":{},\"id\":\"1356\",\"type\":\"UnionRenderers\"},{\"attributes\":{\"data_source\":{\"id\":\"1324\"},\"glyph\":{\"id\":\"1326\"},\"hover_glyph\":null,\"muted_glyph\":null,\"nonselection_glyph\":{\"id\":\"1327\"},\"selection_glyph\":null,\"view\":{\"id\":\"1329\"}},\"id\":\"1328\",\"type\":\"GlyphRenderer\"},{\"attributes\":{\"source\":{\"id\":\"1324\"}},\"id\":\"1329\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"orange\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"orange\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1344\",\"type\":\"Circle\"},{\"attributes\":{\"source\":{\"id\":\"1341\"}},\"id\":\"1346\",\"type\":\"CDSView\"},{\"attributes\":{\"fill_alpha\":{\"value\":0.1},\"fill_color\":{\"value\":\"#1f77b4\"},\"line_alpha\":{\"value\":0.1},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1327\",\"type\":\"Circle\"},{\"attributes\":{\"click_policy\":\"hide\",\"items\":[{\"id\":\"1340\"},{\"id\":\"1358\"}],\"location\":\"top_left\"},\"id\":\"1339\",\"type\":\"Legend\"},{\"attributes\":{\"fill_color\":{\"value\":\"#1f77b4\"},\"line_color\":{\"value\":\"#1f77b4\"},\"x\":{\"field\":\"confidence when correct\"},\"y\":{\"field\":\"confidence when incorrect\"}},\"id\":\"1326\",\"type\":\"Circle\"}],\"root_ids\":[\"1291\"]},\"title\":\"Bokeh Application\",\"version\":\"2.2.1\"}};\n", " var render_items = [{\"docid\":\"779c2c5b-312e-4557-b82d-0e249700ada6\",\"root_ids\":[\"1291\"],\"roots\":{\"1291\":\"73e4077a-f27d-49a3-8545-e4db11f2e984\"}}];\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", " clearInterval(timer);\n", " embed_document(root);\n", " } else {\n", " attempts++;\n", " if (attempts > 100) {\n", " clearInterval(timer);\n", " console.log(\"Bokeh: ERROR: Unable to run BokehJS code because BokehJS library is missing\");\n", " }\n", " }\n", " }, 10, root)\n", " }\n", "})(window);" ], "application/vnd.bokehjs_exec.v0+json": "" }, "metadata": { "application/vnd.bokehjs_exec.v0+json": { "id": "1291" } }, "output_type": "display_data" } ], "source": [ "p.output_backend = \"svg\"\n", "\n", "bokeh.io.show(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now, click the disk icon, and then switch back." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "p.output_backend = \"canvas\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also save the figure programmatically using the `bokeh.io.export_svgs()` function. Again, this will only work if the output backed is `\"svg\"`." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "p.output_backend = \"svg\"\n", "bokeh.io.export_svgs(p, filename=\"insomniac_confidence_correct.svg\")\n", "p.output_backend = \"canvas\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, to save as HTML, you can use the `bokeh.io.save()` function. This saves your plot as a standalone HTML page. Note that the `title` kwarg is not the title of the plot, but the title of the web page that will appear on your Browser tab." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/bois/opt/anaconda3/lib/python3.8/site-packages/bokeh/io/saving.py:126: UserWarning: save() called but no resources were supplied and output_file(...) was never called, defaulting to resources.CDN\n", " warn(\"save() called but no resources were supplied and output_file(...) was never called, defaulting to resources.CDN\")\n" ] }, { "data": { "text/plain": [ "'/Users/bois/Dropbox/git/bebi103_course/2020/a/content/lessons/06/insomniac_confidence_correct.html'" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bokeh.io.save(\n", " p, \n", " filename=\"insomniac_confidence_correct.html\", \n", " title=\"Bokeh plot\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "(You can ignore the warning.) The resulting HTML page has all of the interactivity of the plot and you can, for example, email it to your collaborators for them to explore." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Computing environment" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPython 3.8.5\n", "IPython 7.18.1\n", "\n", "numpy 1.19.1\n", "scipy 1.5.0\n", "pandas 1.1.1\n", "bokeh 2.2.1\n", "jupyterlab 2.2.6\n" ] } ], "source": [ "%load_ext watermark\n", "%watermark -v -p numpy,scipy,pandas,bokeh,jupyterlab" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python 3", "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.8.5" } }, "nbformat": 4, "nbformat_minor": 4 }