Skip to content

Commit

Permalink
Merge 6f0a275 into 26fea8b
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuang11 committed Aug 17, 2019
2 parents 26fea8b + 6f0a275 commit 799e623
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions holoviews/plotting/mpl/element.py
Expand Up @@ -698,13 +698,17 @@ class ColorbarPlot(ElementPlot):
symmetric = param.Boolean(default=False, doc="""
Whether to make the colormap symmetric around zero.""")

extend = param.ObjectSelector(
objects=['neither', 'both', 'min', 'max'], default=None, doc="""
If not 'neither', make pointed end(s) for out-of- range values."""
)

_colorbars = {}

_default_nan = '#8b8b8b'

def __init__(self, *args, **kwargs):
super(ColorbarPlot, self).__init__(*args, **kwargs)
self._cbar_extend = 'neither'

def _adjust_cbar(self, cbar, label, dim):
noalpha = math.floor(self.style[self.cyclic_index].get('alpha', 1)) == 1
Expand Down Expand Up @@ -773,7 +777,7 @@ def _draw_colorbar(self, element=None, dimension=None, redraw=True):
scaled_w = w*width
cax = fig.add_axes([l+w+padding+(scaled_w+padding+w*0.15)*offset,
b, scaled_w, h])
cbar = fig.colorbar(artist, cax=cax, ax=axis, extend=self._cbar_extend)
cbar = fig.colorbar(artist, cax=cax, ax=axis, extend=self.extend)
self._set_axis_formatter(cbar.ax.yaxis, dimension, self.cformatter)
self._adjust_cbar(cbar, label, dimension)
self.handles['cax'] = cax
Expand Down Expand Up @@ -890,12 +894,15 @@ def _norm_kwargs(self, element, ranges, opts, vdim, values=None, prefix=''):
el_min, el_max = -np.inf, np.inf
vmin = -np.inf if opts[prefix+'vmin'] is None else opts[prefix+'vmin']
vmax = np.inf if opts[prefix+'vmax'] is None else opts[prefix+'vmax']
if el_min < vmin and el_max > vmax:
self._cbar_extend = 'both'
elif el_min < vmin:
self._cbar_extend = 'min'
elif el_max > vmax:
self._cbar_extend = 'max'
if self.extend is None:
if el_min < vmin and el_max > vmax:
self.extend = 'both'
elif el_min < vmin:
self.extend = 'min'
elif el_max > vmax:
self.extend = 'max'
else:
self.extend = 'neither'

# Define special out-of-range colors on colormap
colors = {}
Expand Down

0 comments on commit 799e623

Please sign in to comment.