Skip to content

Commit

Permalink
Implemented mpl Contour colormapping
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed May 31, 2017
1 parent 29c0109 commit 18b72bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/__init__.py
Expand Up @@ -147,7 +147,7 @@ def grid_selector(grid):
Text: TextPlot,

# Path plots
Contours: PathPlot,
Contours: ContourPlot,
Path: PathPlot,
Box: PathPlot,
Bounds: PathPlot,
Expand Down
23 changes: 23 additions & 0 deletions holoviews/plotting/mpl/path.py
Expand Up @@ -33,6 +33,29 @@ def update_handles(self, key, axis, element, ranges, style):
return axis_kwargs


class ContourPlot(PathPlot, ColorbarPlot):

style_opts = PathPlot.style_opts + ['cmap']

def get_data(self, element, ranges, style):
args, style, axis_kwargs = super(ContourPlot, self).get_data(element, ranges, style)
value = element.level
if element.vdims and value is not None and np.isfinite(value) and 'cmap' in style:
self._norm_kwargs(element, ranges, style, element.vdims[0])
style['clim'] = style.pop('vmin'), style.pop('vmax')
style['array'] = np.array([value]*len(args[0]))
return args, style, axis_kwargs


def update_handles(self, key, axis, element, ranges, style):
artist = self.handles['artist']
axis_kwargs = super(ContourPlot, self).update_handles(key, axis, element, ranges, style)
if 'array' in style:
artist.set_array(style['array'])
artist.set_clim(style['clim'])
return axis_kwargs


class PolygonPlot(ColorbarPlot):
"""
PolygonPlot draws the polygon paths in the supplied Polygons
Expand Down

0 comments on commit 18b72bc

Please sign in to comment.