0

I tried to reproduce the solution from: How do I work with images in Bokeh (Python) , but it doesn't work. For that, I find an image on the net and put it in place of the 'url' field but the plot is just blank! From the original solution bokeh ask me to add up w and h params which I suppose are the width and height of the pic. Also I dropped x_range and y_range within figure() to wipe out the horizontal and vertical lines of the plot.

from bokeh.plotting import figure, show, output_notebook
output_notebook()

p = figure()
p.image_url( url=[ "http://pngimg.com/uploads/palm_tree/palm_tree_PNG2504.png"], 
             x=1, y=1, w=253, h=409)
show( p)

Anyone could tell me what's going on ?

Community
  • 1
  • 1
alEx
  • 193
  • 6
  • 12
  • This is really a duplicate of the question that you had linked, I've updated the answer in the original post so that it works correctly on 0.12.5. – johnf Apr 24 '17 at 00:30

1 Answers1

2

Bokeh can't auto-range ImageURL it seems. So if there are no other glyphs, you need to provide explicit ranges. Additionlly, the default anchor is upper_left IIRC so it may be that our image is rendering off-canvas and you don't realize it. The code below works with Bokeh 0.12.5:

from bokeh.plotting import figure, show, output_file
output_file("foo.html")

p = figure(x_range=(0,500), y_range=(0,500))
p.image_url( url=[ "http://pngimg.com/uploads/palm_tree/palm_tree_PNG2504.png"],
             x=1, y=1, w=253, h=409, anchor="bottom_left")
show(p)

Without the anchor set, the image plots blow the plot region (have to pan to see it)

bigreddot
  • 33,642
  • 5
  • 69
  • 122