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
merged 21 commits into from Sep 14, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+12 −10
Diff settings

Always

Just for now

Added client side colormapping for PolygonPlot

  • Loading branch information...
Philipp Rudiger Philipp Rudiger
Philipp Rudiger authored and Philipp Rudiger committed Sep 13, 2016
commit 883e185dc5da1c1cca21d374862a0d3afd5f7e27
@@ -7,7 +7,7 @@

from ...core import util
from ..util import map_colors
from .element import ElementPlot, line_properties, fill_properties
from .element import ElementPlot, ColorbarPlot, line_properties, fill_properties
from .util import get_cmap, rgb2hex


@@ -44,7 +44,7 @@ def get_batched_data(self, element, ranges=None, empty=False):
return data, elmapping


class PolygonPlot(PathPlot):
class PolygonPlot(ColorbarPlot, PathPlot):

style_opts = ['color', 'cmap', 'palette'] + line_properties + fill_properties
_plot_methods = dict(single='patches', batched='patches')
@@ -74,15 +74,17 @@ def get_data(self, element, ranges=None, empty=False):
data = dict(xs=ys, ys=xs) if self.invert_axes else dict(xs=xs, ys=ys)

style = self.style[self.cyclic_index]
cmap = style.get('palette', style.get('cmap', None))
mapping = dict(self._mapping)
if cmap and element.level is not None:
cmap = get_cmap(cmap)
colors = map_colors(np.array([element.level]), ranges[element.vdims[0].name], cmap)
mapping['color'] = 'color'
data['color'] = [] if empty else list(colors)*len(element.data)
dim_name = util.dimension_sanitizer(element.vdims[0].name)

if element.vdims and element.level is not None:
cdim = element.vdims[0]
mapper = self._get_colormapper(cdim, element, ranges, style)
data[cdim.name] = [] if empty else element.dimension_values(2)
mapping['fill_color'] = {'field': cdim.name,
'transform': mapper}

if 'hover' in self.tools+self.default_tools:
dim_name = util.dimension_sanitizer(element.vdims[0].name)
for k, v in self.overlay_dims.items():
dim = util.dimension_sanitizer(k.name)
data[dim] = [v for _ in range(len(xs))]
@@ -99,7 +101,7 @@ def get_batched_data(self, element, ranges=None, empty=False):
eldata, elmapping = self.get_data(el, ranges, empty)
for k, eld in eldata.items():
data[k].extend(eld)
if 'color' not in eldata:
if 'color' not in elmapping:
zorder = self.get_zorder(element, key, el)
val = style[zorder].get('color')
elmapping['color'] = 'color'
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.