Agus Abdullah
Agus Abdullah

Reputation: 31

plot image with interpolation in Python Bokeh like matplotlib?

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.

Upvotes: 1

Views: 1301

Answers (3)

Hugo Santos Silva
Hugo Santos Silva

Reputation: 95

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')

Upvotes: 2

sirspoon
sirspoon

Reputation: 35

Not an answer but an observation - I've noticed that plotting an image via an image_url source it appears interpolated when zoomed in whilst if you read in the same image and display it from a columndatasource via 'image' it then appears blocky when zoomed. I'd love to know how to make it appear interpolated too when zoomed, eg like the raw png image appears. Holoview/datashader would be a great solution but in my case I need it to work offline/as a standalone html file.

Upvotes: 0

Tony
Tony

Reputation: 8297

If you are working with a large dataset then you could try Bokeh in combination with Datashader/HoloViews like in this example. When zooming in, Datashader can dynamically create new high quality images from your data that could be displayed in your Bokeh plot.

Upvotes: 0

Related Questions