diff --git a/kabuki/actor.py b/kabuki/actor.py index 426493c..9504bd6 100644 --- a/kabuki/actor.py +++ b/kabuki/actor.py @@ -1,7 +1,7 @@ from .frame import Frame from .logic import decide_src_plt_cfg -from .cfgdlgs import ConfigDialog1D #TODO +from .cfgdlgs import ConfigDialog1D, ConfigDialog2D #TODO class Actor: @@ -29,6 +29,11 @@ class Actor: cfg.error_bands.on_click(plt.show_error_bands) cfg.error_bars.on_click(plt.show_error_bars) + if isinstance(cfg, ConfigDialog2D): #TODO + cfg.sel_cmap.value = plt.palette + + cfg.sel_cmap.on_change("value", lambda _attr, _old, new: plt.change_cmap(new)) + def delete(self): self.cache = None diff --git a/kabuki/cfgdlgs/cfgdlg2d.py b/kabuki/cfgdlgs/cfgdlg2d.py index b8a5686..5fa3fa6 100644 --- a/kabuki/cfgdlgs/cfgdlg2d.py +++ b/kabuki/cfgdlgs/cfgdlg2d.py @@ -1,14 +1,26 @@ -from bokeh.models import TextInput +from bokeh.models import Select, TextInput from ..buki import Column +CMAPS = [ + "Plasma", + "Turbo", + "Viridis" +] + + class ConfigDialog2D(Column): def __init__(self): self.ti_cache_size = ti_cache_size = TextInput(value="", title="Cache size:") ti_cache_size.disabled = True # 2D plot only shows the latest image - super().__init__(ti_cache_size) + self.sel_cmap = sel_cmap = Select(title="Colormap", options=CMAPS) + super().__init__(ti_cache_size, sel_cmap) + + + +#TODO: vmin, vmax, binning, log diff --git a/kabuki/plots/plot2d.py b/kabuki/plots/plot2d.py index 0200cb0..cb6297a 100644 --- a/kabuki/plots/plot2d.py +++ b/kabuki/plots/plot2d.py @@ -2,6 +2,7 @@ import numpy as np from bokeh.plotting import figure from bokeh.models import ColumnDataSource, ColorBar, LinearColorMapper +from bokeh.palettes import all_palettes from ..buki import Object @@ -15,7 +16,8 @@ class Plot2D(Object): self.source = source = ColumnDataSource(data=data) - cmap = LinearColorMapper(palette="Viridis256") + self.cmap = cmap = LinearColorMapper() + self.change_cmap("Viridis") cbar = ColorBar(color_mapper=cmap) fig = figure(name=name, match_aspect=True) @@ -33,4 +35,9 @@ class Plot2D(Object): self.source.data.update(image=[image]) + def change_cmap(self, name): + self.palette = name + self.cmap.palette = all_palettes[name][256] + +