Skip to content

Commit

Permalink
Merge pull request #729 from ioam/bokeh_logz
Browse files Browse the repository at this point in the history
Added support for LogColorMapper in bokeh Raster plots
  • Loading branch information
jlstevens committed Jun 22, 2016
2 parents 564d747 + b206fcf commit b37021d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import param

from bokeh.models.mappers import LinearColorMapper
try:
from bokeh.models.mappers import LogColorMapper
except ImportError:
LogColorMapper = None

from ...core.util import cartesian_product
from ...element import Image, Raster, RGB
Expand All @@ -13,6 +17,9 @@

class RasterPlot(ElementPlot):

logz = param.Boolean(default=False, doc="""
Whether to apply log scaling to the z-axis.""")

show_legend = param.Boolean(default=False, doc="""
Whether to show legend for the plot.""")

Expand Down Expand Up @@ -53,7 +60,8 @@ def _glyph_properties(self, plot, element, source, ranges):
low, high = ranges.get(val_dim)
if 'cmap' in properties:
palette = mplcmap_to_palette(properties.pop('cmap', None))
cmap = LinearColorMapper(palette, low=low, high=high)
colormapper = LogColorMapper if self.logz else LinearColorMapper
cmap = colormapper(palette, low=low, high=high)
properties['color_mapper'] = cmap
if 'color_mapper' not in self.handles:
self.handles['color_mapper'] = cmap
Expand Down

0 comments on commit b37021d

Please sign in to comment.