像matplotlib一样在Python Bokeh中使用插值绘制图像? [英] plot image with interpolation in Python Bokeh like matplotlib?
问题描述
有没有办法像使用Matplotlib一样,使用具有插值的Bokeh将2D数组绘制为图像?我可以使用示例进行绘制: https://docs.bokeh .org/en/latest/docs/gallery/image.html 但是,图像太粗糙了.我喜欢Matplotlib中插值的工作方式: https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods .html
Is there any way to plot 2D array as an image using Bokeh with interpolation like in Matplotlib? I am able to plot using an example: https://docs.bokeh.org/en/latest/docs/gallery/image.html However, the image is to coarse. I like the way interpolation work in Matplotlib: https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods.html
我尝试过预先执行插值,但是矩阵的大小现在很大.
I tried to perform interpolation beforehand but the matrix size now is to big.
推荐答案
我遇到了同样的问题,并且在pyviz的Gitter中找到了答案.
该解决方案结合了Holoviews
和Datashader
:
I had the same issue and I've found the answer in pyviz's Gitter.
The solution combines Holoviews
and Datashader
:
import holoviews as hv
from holoviews import opts
from holoviews.operation.datashader import regrid
img = hv.Image(data)
regrid(img, upsample=True, interpolation='bilinear')
这篇关于像matplotlib一样在Python Bokeh中使用插值绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!