bokeh#

fivecentplots v0.6 provides limited support for using bokeh in place of matplotlib as the plotting engine.

Setup#

First-time setup:

bokeh is not currently part of the default pacakge requirements for fcp so it is not automatically installed. For inline usage:

[ ]:
pip install bokeh

Switching engines:

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

Per-plot:

[ ]:
fcp.plot(df, x='x', y='y', engine='bokeh')

Global:

[ ]:
fcp.KWARGS['engine'] = 'bokeh'

Themes:

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:

[ ]:
fcp.set_theme('gray_bokeh')

Maturity:

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.

Import packages


import fivecentplots as fcp
import pandas as pd
from pathlib import Path

Engine and themes#


fcp.KWARGS['inline'] = True
fcp.KWARGS['engine'] = 'bokeh'

fcp.set_theme('gray_bokeh')
Previous theme file found! Renaming to "defaults_old.py" and copying theme "gray_bokeh"...done!

Sample data#


df_xy = pd.read_csv(Path(fcp.__file__).parent / 'test_data/fake_data.csv')
df_xy.head(10)

Substrate Target Wavelength Boost Level Temperature [C] Die Voltage I Set I [A]
0 Si 450 0.2 25 (1,1) 0.0 0.0 0.0
1 Si 450 0.2 25 (1,1) 0.1 0.0 0.0
2 Si 450 0.2 25 (1,1) 0.2 0.0 0.0
3 Si 450 0.2 25 (1,1) 0.3 0.0 0.0
4 Si 450 0.2 25 (1,1) 0.4 0.0 0.0
5 Si 450 0.2 25 (1,1) 0.5 0.0 0.0
6 Si 450 0.2 25 (1,1) 0.6 0.0 0.0
7 Si 450 0.2 25 (1,1) 0.7 0.0 0.0
8 Si 450 0.2 25 (1,1) 0.8 0.0 0.0
9 Si 450 0.2 25 (1,1) 0.9 0.0 0.0

plot#

No legend#


fcp.plot(df_xy, x='Voltage', y='I [A]', lines=False, ax_size=[400, 400])
Loading BokehJS ...

Filtered#


fcp.plot(df_xy, x='Voltage', y='I [A]', title='IV Data', lines=False,
         filter='Substrate=="Si" & Target Wavelength==450 & Boost Level==0.2 & Temperature [C]==25')

Legend#


fcp.plot(df_xy, x='Voltage', y='I [A]', legend='Die',
         filter='Substrate=="Si" & Target Wavelength==450 & Boost Level==0.2 & Temperature [C]==25')

Log axis#

Note

symlog and logit not yet supported


fcp.plot(df_xy, x='Voltage', y='I [A]', ax_scale='loglog', legend='Die', xmin=0.9, xmax=2.1, grid_minor=True,
         filter='Substrate=="Si" & Target Wavelength==450 & Boost Level==0.2 & Temperature [C]==25')

Time series#


ts = pd.read_csv(Path(fcp.__file__).parent / 'test_data/fake_ts.csv')
fcp.plot(ts, x='Date', y='Happiness Quotient', markers=False, ax_size=[1000, 250])

Secondary axes#


fcp.plot(df_xy, x='Voltage', y=['Voltage', 'I [A]'], twin_x=True, legend='Die',
         grid_major_y2=True, grid_major_y2_style='--', y2max=1.4,
         filter='Substrate=="Si" & Target Wavelength==450 & Boost Level==0.2 & Temperature [C]==25 & Die=="(-1,2)"')

Multiple x & y values#


fcp.plot(df_xy, x=['Boost Level', 'I [A]'], y=['Voltage', 'Temperature [C]'], legend='Die',
         filter='Substrate=="Si" & Target Wavelength==450 & Boost Level==0.2 & Temperature [C]==25')

Grouping#

Row plot#


fcp.plot(df_xy, x='Voltage', y='I [A]', legend='Die', row='Boost Level', ax_size=[225, 225],
         filter='Substrate=="Si" & Target Wavelength==450 & Temperature [C]==25')

Column plot#


fcp.plot(df_xy, x='Voltage', y='I [A]', legend='Die', col='Boost Level', ax_size=[225, 225],
         filter='Substrate=="Si" & Target Wavelength==450 & Temperature [C]==25')

Row x column grid#


fcp.plot(df_xy, x='Voltage', y='I [A]', legend='Die', col='Boost Level', row='Temperature [C]',
         ax_size=[225, 225], filter='Substrate=="Si" & Target Wavelength==450')

That’s it for now…