Bokeh

Video Walkthrough

What will you get with this integration?

Bokeh is a Python library for creating interactive visualizations for modern web browsers. It helps you build beautiful graphics, ranging from simple plots to complex dashboards with streaming datasets. With Bokeh, you can create JavaScript-powered visualizations without writing any JavaScript yourself.

This integration lets you log interactive charts generated in bokeh to Neptune.

Introduction

This guide will show you how to:

  • Initialize Neptune and create a run,

  • Log bokeh charts to Neptune.

Step 0: Before you start

Install neptune-client and bokeh

pip install neptune-client bokeh

This integration is tested with neptune-client==0.9.19 and bokeh==2.3.2

Step 1: Import and initialize neptune

import neptune.new as neptune
run = neptune.init(api_token='<your_api_token>', project='<your_project_name>')

You can use the api_token='ANONYMOUS' and project='common/bokeh-support' to explore without having to create a Neptune account

Executing this cell will give you a link looking like: https://app.neptune.ai/common/bokeh-support/e/BOK-9 with common/bokeh-support replaced by your project, and BOK-9 replaced by your run.

Click on the link to open the run in Neptune. For now, it is empty but keep the tab with the run open to see what happens next.

Step 2: Log Bokeh figures to Neptune

Create a sample figure

import numpy as np
from bokeh.plotting import figure
N = 500
x = np.linspace(0, 10, N)
y = np.linspace(0, 10, N)
xx, yy = np.meshgrid(x, y)
d = np.sin(xx)*np.cos(yy)
p = figure(tooltips=[("x", "$x"), ("y", "$y"), ("value", "@image")])
p.x_range.range_padding = p.y_range.range_padding = 0
# must give a vector of image data for image parameter
p.image(image=[d], x=0, y=0, dw=10, dh=10, palette="Spectral11", level="image")
p.grid.grid_line_width = 0.5

Log interactive figure

run['interactive_img'].upload(neptune.types.File.as_html(p))

Step 3: Stop logging

Once you are done logging, you should stop tracking the run using the stop() method. This is needed only while logging from a notebook environment. While logging through a script, Neptune automatically stops tracking once the script has completed execution.

run.stop()

Step 4: Explore the results in the Neptune

The images can be found in the All Metadata section:

Conclusion

You have learned how to:

  • Initialize Neptune and create a run,

  • Log bokeh charts to Neptune.

What's next

Now that you know how to log charts to Neptune, you can learn: