diff --git a/holoviews/plotting/bokeh/__init__.py b/holoviews/plotting/bokeh/__init__.py index 5d66b90d6e..9e082a31f6 100644 --- a/holoviews/plotting/bokeh/__init__.py +++ b/holoviews/plotting/bokeh/__init__.py @@ -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) @@ -66,7 +66,7 @@ # Paths Path: PathPlot, - Contours: PathPlot, + Contours: ContourPlot, Path: PathPlot, Box: PathPlot, Bounds: PathPlot, diff --git a/holoviews/plotting/bokeh/path.py b/holoviews/plotting/bokeh/path.py index d5d0acfd48..28a9feb667 100644 --- a/holoviews/plotting/bokeh/path.py +++ b/holoviews/plotting/bokeh/path.py @@ -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