10

Can someone give a short/simple example of how to plot a 2D-array with bokeh? Something similar to imshow() in matplotlib. I did not find a good examples given in the bokeh gallery.

a = np.array([[1,2], [3, 4]])
imshow(a)  # but with bokeh
2
  • 1
    That is what I am asking about. Code. I don't know any code that does that. That is the point. Commented May 18, 2018 at 23:37
  • Not sure why this was downvoted. Is bokeh.pydata.org/en/latest/docs/gallery/image.html what you want? Commented May 18, 2018 at 23:48

1 Answer 1

9

Thanks Adian! That was a good direction. Here is a minimal example.

import numpy as np
from bokeh.plotting import figure, show

a = np.array([[1,2], [3, 4]])
p = figure(x_range=(0, 2), y_range=(0, 2))

# must give a vector of image data for image parameter
p.image(image=[a], x=0, y=0, dw=2, dh=2, palette="Spectral11")

show(p)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.