How to add local stored image to bokeh plot in jupyter lab

Viewed 120

I would like to add an image to a bokeh plot. I get it to work with a web-based url. But when I save the file locally, I don't know to get it working.

import numpy as np

from bokeh.models import ColumnDataSource, Plot, LinearAxis, Grid, ImageURL
from bokeh.models.markers import Circle
from bokeh.io import output_notebook, push_notebook, show
output_notebook()

N = 9
x = np.linspace(-2, 2, N)
y = x**2
sizes = np.linspace(10, 20, N)

source = ColumnDataSource(dict(x=x, y=y, sizes=sizes))

plot = Plot(
    title=None, plot_width=300, plot_height=300,
    min_border=0, toolbar_location=None)

glyph = Circle(x="x", y="y", size="sizes", line_color="#3288bd", fill_color="white", line_width=3)
plot.add_glyph(source, glyph)

url = ["https://static.bokeh.org/logos/logo.png"]
#url = ["logo.png"] <<-- This does not work
image1 = ImageURL(url=url, x=0, y=4, w=2, h=3, anchor="center")
plot.add_glyph(image1)

show(plot)

screenshot

How do I specify the location or the content of the png, to include it into the bokeh plot.

0 Answers
Related