Using local files in bokeh.plotting

93 views Asked by At

I am using bokeh to display pins on a map and want when hoovering to display a JPG. The code below works well when the image is from the internet (i.e. with a URL) but how can I make it work if the image is on the local drive, i.e. 'C:.....\pic.jpg'?

This works:

from bokeh.plotting import ColumnDataSource, figure, output_file, show
source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    desc=['A', 'b', 'C', 'd', 'E'],
    imgs=[
        'https://docs.bokeh.org/static/snake.jpg',
        'https://docs.bokeh.org/static/snake2.png',
        'https://docs.bokeh.org/static/snake3D.png',
        'https://docs.bokeh.org/static/snake4_TheRevenge.png',
        'https://docs.bokeh.org/static/snakebite.jpg'
    ]))

This doesn't work:

from bokeh.plotting import ColumnDataSource, figure, output_file, show
source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    desc=['A', 'b', 'C', 'd', 'E'],
    imgs=[
        'C:\snake.jpg',
        'C:\snake2.png',
        'C:\snake3D.png',
        'C:\snake4_TheRevenge.png',
        'C:\snakebite.jpg'
    ]))
0

There are 0 answers