简体   繁体   中英

Bokeh image glyph displays image upside-down

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.

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM