如何在Bokeh(Python)中处理图像 [英] How do I work with images in Bokeh (Python)
本文介绍了如何在Bokeh(Python)中处理图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,您可以使用以下代码在matplotlib中绘制图像:
For example you can plot an image in matplotlib using this code:
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
img=mpimg.imread('image.png')
plt.imshow(img)
Bokeh(0.10)是否可以这样?在此先感谢您的帮助。
Is something like this possible with Bokeh(0.10)? Thanks in advance for your help.
推荐答案
您可以使用 ImageURL
字形( image_url
绘图方法)在本地或从Web加载图像。
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
output_file('image.html')
p = figure(x_range=(0,1), y_range=(0,1))
p.image_url(url=['tree.png'], x=0, y=1)
show(p)
一个问题 - 如果你只绘制一个图像(没有其他数据),你必须明确设置绘图范围。
One gotcha - if you graph only an image (and no other data), you'll have to explicitly set the plot ranges.
以下是文档:
http://bokeh.pydata.org/en/latest/docs/reference/models/glyphs.html#bokeh.models.glyphs.ImageURL
这篇关于如何在Bokeh(Python)中处理图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文