Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent vmin vmax matplotlib bokeh

I am a new user of bokeh. Although the question is very simple I have not found the answer. In the bokeh library, what is the equivalent of vmax and vmax of matplolib imshow? For example, in Matplolib I use vmin and vmax with these values

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

However, If I use bokeh I get a different result,

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 Vs bokeh result enter image description here

What is my error? Thanks in advance

like image 701
highwaytohell Avatar asked Nov 17 '17 10:11

highwaytohell


1 Answers

With this code it work:

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')
like image 86
highwaytohell Avatar answered Sep 25 '22 12:09

highwaytohell