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

Bokeh colorbars #861

merged 21 commits into from Sep 14, 2016
Changes from 1 commit
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+6 −21
Diff settings


Just for now

Added colorbars for RasterPlot

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed Sep 13, 2016
commit ac35b2f4330a9ce5e1d5abdbd621e4010f0b069a
@@ -1,24 +1,15 @@
import numpy as np
import param

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

from ...core.util import cartesian_product
from ...element import Image, Raster, RGB
from ..renderer import SkipRendering
from ..util import map_colors
from .element import ElementPlot, line_properties, fill_properties
from .util import mplcmap_to_palette, get_cmap, hsv_to_rgb

from .element import ElementPlot, ColorbarPlot, line_properties, fill_properties
from .util import mplcmap_to_palette, get_cmap, hsv_to_rgb, mpl_to_bokeh

class RasterPlot(ElementPlot):

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

show_legend = param.Boolean(default=False, doc="""
Whether to show legend for the plot.""")
@@ -56,15 +47,9 @@ def _glyph_properties(self, plot, element, source, ranges):
properties = super(RasterPlot, self)._glyph_properties(plot, element,
source, ranges)
properties = {k: v for k, v in properties.items()}
val_dim = [ for d in element.vdims][0]
low, high = ranges.get(val_dim)
if 'cmap' in properties:
palette = mplcmap_to_palette(properties.pop('cmap', None))
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
val_dim = [d for d in element.vdims][0]
properties['color_mapper'] = self._get_colormapper(val_dim, element, ranges,
return properties

This comment has been minimized.

Copy link

jlstevens Sep 14, 2016


I'm just wondering why in this case self._get_colormapper is used to add the color mapper to the properties (in _glyph_properties) but is added to the data in get_data everywhere else...

This comment has been minimized.

Copy link

philippjfr Sep 14, 2016

Author Contributor

The image glyph accepts a colormapper directly while in other cases it is used as a transform that maps color to a particular column.

This comment has been minimized.

Copy link

jlstevens Sep 14, 2016


Thanks for the explanation!

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.