Skip to content

Commit

Permalink
Add support for colormapping Contours
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 31, 2017
1 parent f0fa434 commit 9cc0551
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from .chart import (PointPlot, CurvePlot, SpreadPlot, ErrorPlot, HistogramPlot,
SideHistogramPlot, BarPlot, SpikesPlot, SideSpikesPlot,
AreaPlot, VectorFieldPlot)
from .path import PathPlot, PolygonPlot
from .path import PathPlot, PolygonPlot, ContourPlot
from .plot import GridPlot, LayoutPlot, AdjointLayoutPlot
from .raster import (RasterPlot, RGBPlot, HeatmapPlot,
HSVPlot, QuadMeshPlot)
Expand Down Expand Up @@ -66,7 +66,7 @@

# Paths
Path: PathPlot,
Contours: PathPlot,
Contours: ContourPlot,
Path: PathPlot,
Box: PathPlot,
Bounds: PathPlot,
Expand Down
18 changes: 18 additions & 0 deletions holoviews/plotting/bokeh/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ def get_batched_data(self, element, ranges=None, empty=False):
return data, elmapping


class ContourPlot(ColorbarPlot, PathPlot):

style_opts = line_properties + ['cmap']

def get_data(self, element, ranges=None, empty=False):
data, mapping = super(ContourPlot, self).get_data(element, ranges, empty)
ncontours = len(list(data.values())[0])
style = self.style[self.cyclic_index]
if element.vdims and element.level is not None:
cdim = element.vdims[0]
dim_name = util.dimension_sanitizer(cdim.name)
cmapper = self._get_colormapper(cdim, element, ranges, style)
data[dim_name] = [] if empty else np.full(ncontours, element.level)
mapping['line_color'] = {'field': dim_name,
'transform': cmapper}
return data, mapping


class PolygonPlot(ColorbarPlot, PathPlot):

style_opts = ['cmap', 'palette'] + line_properties + fill_properties
Expand Down

0 comments on commit 9cc0551

Please sign in to comment.