Last active
April 9, 2019 17:24
-
-
Save lovit/6fcd33bc2963b5c2f748e16f9ac2c9dc to your computer and use it in GitHub Desktop.
Bokeh (1.0.4) image show example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# replace matplotlib.pyplot.imshow(img) | |
import numpy as np | |
from bokeh.plotting import figure, show, output_notebook | |
output_notebook() | |
N = 500 | |
x = np.linspace(0, 10, N) | |
y = np.linspace(0, 10, N) | |
xx, yy = np.meshgrid(x, y) | |
d = np.sin(xx)*np.cos(yy) # (500, 500) numpy.ndarray | |
p = figure(x_range=(0, 10), y_range=(0, 10)) | |
p.image(image=[d], x=0, y=0, dw=10, dh=10, palette="Spectral11") # uni channel with palette | |
show(p) | |
# figure size (10, 15) but image only (10, 10) | |
p = figure(x_range=(0, 10), y_range=(0, 15)) | |
p.image(image=[d], x=0, y=0, dw=10, dh=10) # grey image | |
show(p) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hover tool style