diff --git a/kabuki/cfgdlgs/cfgdlg2d.py b/kabuki/cfgdlgs/cfgdlg2d.py index ba492d6..925d6de 100644 --- a/kabuki/cfgdlgs/cfgdlg2d.py +++ b/kabuki/cfgdlgs/cfgdlg2d.py @@ -1,22 +1,16 @@ from bokeh.models import Select, Spinner from ..buki import Column, Row +from ..colormaps import cmaps from ..widgets import Checkbox -CMAPS = [ - "Plasma", - "Turbo", - "Viridis" -] - - class ConfigDialog2D(Column): def __init__(self): self.sp_cache_size = sp_cache_size = Spinner(title="Cache size:") sp_cache_size.disabled = True # 2D plot only shows the latest image - self.sel_cmap_palette = sel_cmap_palette = Select(title="Colormap", options=CMAPS) + self.sel_cmap_palette = sel_cmap_palette = Select(title="Colormap", options=sorted(cmaps)) self.cb_cmap_reverse = cb_cmap_reverse = Checkbox(label="Reverse Colormap") self.sp_vmin = sp_vmin = Spinner(title="Minimum Value") self.sp_vmax = sp_vmax = Spinner(title="Maximum Value") diff --git a/kabuki/colormaps.py b/kabuki/colormaps.py new file mode 100644 index 0000000..db23f54 --- /dev/null +++ b/kabuki/colormaps.py @@ -0,0 +1,59 @@ +from bokeh.palettes import ( + Viridis256, + Cividis256, + + Inferno256, + Magma256, + Plasma256, + + Turbo256, + Greys256 +) + +from colorcet import ( + fire, + rainbow, + isolum, + + coolwarm, + bkr, + b_diverging_gwr_55_95_c38 +) + + +cmaps = { + # viridian: + "Viridis": Viridis256, + "Cividis": Cividis256, + + # fiery: + "Fire": fire, + "Inferno": Inferno256, + "Magma": Magma256, + "Plasma": Plasma256, + + # spectral + "Rainbow": rainbow, + "Turbo": Turbo256, + "Greyscale": Greys256, + "IsoLum": isolum, + + # divergent + "CoolWarm": coolwarm, + "CoolBlackWarm": bkr, + "Italia": b_diverging_gwr_55_95_c38 +} + + + +#TODO: Alternatives to Greys? +# Blues +# Greens +# Oranges +# Purples +# Reds + +#TODO: cyclic? + + + diff --git a/kabuki/plots/plot2d.py b/kabuki/plots/plot2d.py index fd8e30c..ea9d7ef 100644 --- a/kabuki/plots/plot2d.py +++ b/kabuki/plots/plot2d.py @@ -1,9 +1,9 @@ import numpy as np from bokeh.models import ColumnDataSource, ColorBar, LinearColorMapper -from bokeh.palettes import all_palettes from bokeh.plotting import figure +from ..colormaps import cmaps from ..buki import Object @@ -49,7 +49,7 @@ class Plot2D(Object): self._update_cmap() def _update_cmap(self): - pal = all_palettes[self.cmap_palette][256] + pal = cmaps[self.cmap_palette] if self.cmap_reverse: pal = pal[::-1] self.cmap.palette = pal