Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bokeh image glyph displays image upside-down

Tags:

python

bokeh

Bokeh image glyph shows images upside-down and y-axis does not conform to standards of image display, where tick mark zero starts at the top (matrix-like notation).

from scipy.misc import lena
import bokeh.plotting as bp
import matplotlib.pyplot as plt

bp.output_notebook()
%matplotlib inline

lena_img = lena()/256.0

plt.figure(figsize=(10, 10))
plt.imshow(lena_img, cmap='gray')
plt.show()

f1 = bp.figure(plot_width=512, plot_height=512, 
               x_range=[0, 512], y_range=[0, 512], logo='grey')
f1.image(image=image=[lena_img], x=[0], y=[0], 
         dw=[512], dh=[512], palette='Greys9')
f1.title = 'Lena upside-down'
f1.title_text_color = 'red'
f1.title_text_font_style = 'bold'
bp.show(f1)

Is there a solution other than flipping image lena_img[::-1, :]? This still leaves y-axis in coordinate system mode.

like image 804
Miske Avatar asked Sep 28 '22 21:09

Miske


1 Answers

Same issue with Bokeh image plot.The only thing that worked for me was adding img=np.flipud(img) before plotting img. Of course you will have to import numpy beforehand.

Hope that helps!

like image 179
Amit Solanki Avatar answered Oct 03 '22 02:10

Amit Solanki