Trevor McCormick Trevor McCormick - 9 months ago 138
Python Question

How do I work with images in Bokeh (Python)

For example you can plot an image in matplotlib using this code:

%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

Is something like this possible with Bokeh(0.10)? Thanks in advance for your help.


You can use the ImageURL glyph (image_url plot method)to load images locally or from the web.

from bokeh.plotting import figure, show, output_file


p = figure(x_range=(0,1), y_range=(0,1))
p.image_url(url=['tree.png'], x=0, y=1)

Image Example

One gotcha - if you graph only an image (and no other data), you'll have to explicitly set the plot ranges.

Here's the docs: