{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# bokeh" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**fivecentplots** v0.6 provides limited support for using `bokeh` in place of `matplotlib` as the plotting engine. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " First-time setup:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`bokeh` is not currently part of the default pacakge requirements for fcp so it is not automatically installed. For inline usage:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pip install bokeh" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Switching engines: \n", "\n", "Since `matplotlib` is the default plotting engine in **fivecentplots**, the user must manually invoke the `bokeh` engine. This can be done on a per-plot basis via the `engine` kwarg or by updating the global kwargs so the change persists within the users current interactive environment\n", "\n", "Per-plot:\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fcp.plot(df, x='x', y='y', engine='bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Global:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fcp.KWARGS['engine'] = 'bokeh'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ " Themes: \n", "\n", "Due to differences between plotting libraries, it was found that the default **fivecentplots** theme files were not ideal in `bokeh`. It is also therefore recommended to update to a `bokeh`-specific theme when using this engine:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "fcp.set_theme('gray_bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Maturity:\n", "\n", "`bokeh` support for **fivecentplots** is currently limited to basic x-y scatter plots. This could be extended further in the future if a developer decides to take on the project. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import packages" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import fivecentplots as fcp\n", "import pandas as pd\n", "from pathlib import Path" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Engine and themes" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "fcp.KWARGS['inline'] = True\n", "fcp.KWARGS['engine'] = 'bokeh'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Previous theme file found! Renaming to \"defaults_old.py\" and copying theme \"gray_bokeh\"...done!\n" ] } ], "source": [ "fcp.set_theme('gray_bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Sample data" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | Substrate | \n", "Target Wavelength | \n", "Boost Level | \n", "Temperature [C] | \n", "Die | \n", "Voltage | \n", "I Set | \n", "I [A] | \n", "
---|---|---|---|---|---|---|---|---|
0 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.0 | \n", "0.0 | \n", "0.0 | \n", "
1 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.1 | \n", "0.0 | \n", "0.0 | \n", "
2 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.2 | \n", "0.0 | \n", "0.0 | \n", "
3 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.3 | \n", "0.0 | \n", "0.0 | \n", "
4 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.4 | \n", "0.0 | \n", "0.0 | \n", "
5 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.5 | \n", "0.0 | \n", "0.0 | \n", "
6 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.6 | \n", "0.0 | \n", "0.0 | \n", "
7 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.7 | \n", "0.0 | \n", "0.0 | \n", "
8 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.8 | \n", "0.0 | \n", "0.0 | \n", "
9 | \n", "Si | \n", "450 | \n", "0.2 | \n", "25 | \n", "(1,1) | \n", "0.9 | \n", "0.0 | \n", "0.0 | \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 \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"
\\n\"+\n \"