Bokeh image glyph displays image upside-down

梦想与她 提交于 2020-01-04 05:10:49

问题


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.


回答1:


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!



来源:https://stackoverflow.com/questions/28195181/bokeh-image-glyph-displays-image-upside-down

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!