Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for LogColorMapper in bokeh Raster plots #729

Merged
merged 1 commit into from
Jun 22, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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