我是bokeh的新用户。尽管问题很简单,但我还没有找到答案。
在bokeh库中,matplolib imshow的vmax和vmax等效于什么?
例如,在Matplolib中,我将vmin和vmax与这些值一起使用

im = ax.imshow(image_data, vmin = 0.1, vmax = 0.8, origin = 'lower')

但是,如果我使用bokeh,我会得到不同的结果,
p1 = figure(title="my_title",x_range=[min_x,image_data.shape[0]],y_range=[min_y, image_data.shape[1]], toolbar_location=None)
p1.image(image=[image_data], x=[min_x],y=[min_y],dw=[image_data.shape[0]],dh=[image_data.shape[1]], palette="Spectral11")
color_bar = ColorBar(color_mapper=color_mapper, ticker=LogTicker(),
                             label_standoff=12, border_line_color=None, location=(0,0))

imshow与bokeh结果
python - 等效vmin vmax matplotlib散景-LMLPHP

我怎么了提前致谢

最佳答案

使用此代码,它可以工作:

from bokeh.plotting import figure
from bokeh.models.mappers import LogColorMapper
from bokeh.models import ColorBar, LogTicker

color_mapper = LogColorMapper(palette="Viridis256", low=0.1, high=0.8)

plot = figure(x_range=(0,image_data.shape[0]), y_range=(0,image_data.shape[1]),
              toolbar_location=None)
plot.image(image=[image], color_mapper=color_mapper,
           dh=[image_data.shape[0]], dw=[image_data.shape[1]], x=[0], y=[0])

color_bar = ColorBar(color_mapper=color_mapper, ticker=LogTicker(),
                     label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')

关于python - 等效vmin vmax matplotlib散景,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47348287/

10-10 00:14
查看更多