Hi I would like to build an interactive map for oceanographic data exploration.
Basically I want to show several maps which all have linked ranges and colorbars.
I am having trouble implementing an interactive control of the colorlimits.
What I want is a widgetbox with a color_min and color_max slider (or even better a single RangeSlider) to adjust the color_mapper properties min and max.
This is what I have (mostly based on this: https://github.com/bokeh/bokeh/issues/4612), but the figure is not updated when I use the sliders?
import numpy as np
from bokeh.plotting import figure, curdoc, show, output_notebook
from bokeh.layouts import row, layout,widgetbox
from bokeh.models import Slider
from bokeh.models.mappers import LinearColorMapper
from bokeh.palettes import Greys9
def change_image_contrast(attr, old, new):
fig_im.glyph.color_mapper.update(low=graph_min_slider.value, high=graph_max_slider.value)
fig_im.trigger(‘glyph’, fig_im.glyph, fig_im.glyph)
graph_min_slider = Slider(title=“Min”, start=0, end=99, step=1, value=0)
graph_max_slider = Slider(title=“Max”, start=1, end=100, step=1, value=100)
graph_min_slider.on_change(‘value’, change_image_contrast)
graph_max_slider.on_change(‘value’, change_image_contrast)
fig = figure(plot_width=500, plot_height=500, x_range=(0, 10), y_range=(0, 10))
fig_im = fig.image(image=[np.random.randint(0, 100, (10, 10), dtype=‘int16’)], x=[0], y=[0], dw=[10], dh=[10],
color_mapper=LinearColorMapper(low=0, high=100, palette=Greys9))
layout = row(
fig,widgetbox(graph_min_slider,graph_max_slider),
)
show(layout)
``
Am I approaching this wrong? I am very new to bokeh and would be grateful for any advice.