2017-03-18 16 views
0

我試圖從How do I work with images in Bokeh (Python)重現解決方案,但它不起作用。爲此,我在網上找到一張圖片,並將其放置在'url'字段的位置,但情節只是空白!從最初的解決方案散景中,請求我加上w和h參數,我認爲這是圖片的寬度和高度。此外,我還在圖()中刪除了x_range和y_range以消除圖的水平和垂直線。無法在Bokeh(Python)中使image_url工作

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) 

任何人都可以告訴我發生了什麼事?

+0

這確實是問題的一個副本,你已鏈接,我已經在原始文章中更新了答案,以便它在0.12.5上正常工作。 – johnf

回答

1

看起來散景不能自動調節ImageURL。所以如果沒有其他字形,你需要提供明確的範圍。另外,默認的錨點是upper_left IIRC,所以它可能是我們的圖像渲染離開畫布,你沒有意識到。下面的代碼與背景虛化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) 

沒有anchor集,圖像地塊吹積區(具有平移看到它)