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

Add clim opt #3381

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,10 @@ class ColorbarPlot(ElementPlot):
Number of discrete colors to use when colormapping or a set of color
intervals defining the range of values to map each color to.""")

clim = param.NumericTuple(default=(np.nan, np.nan), length=2, doc="""
User-specified colorbar axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.""")

colorbar = param.Boolean(default=False, doc="""
Whether to display a colorbar.""")

Expand Down Expand Up @@ -1405,7 +1409,10 @@ def _get_colormapper(self, eldim, element, ranges, style, factors=None, colors=N

ncolors = None if factors is None else len(factors)
if eldim:
if dim_name in ranges:
# check if there's an actual value (not np.nan)
if sum((~np.isnan(v) for v in self.clim)):
low, high = self.clim
elif dim_name in ranges:
low, high = ranges[dim_name]['combined']
elif isinstance(eldim, dim):
low, high = np.nan, np.nan
Expand Down
8 changes: 8 additions & 0 deletions holoviews/plotting/mpl/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,9 @@ def teardown_handles(self):


class ColorbarPlot(ElementPlot):
clim = param.NumericTuple(default=(np.nan, np.nan), length=2, doc="""
User-specified colorbar axis range limits for the plot, as a tuple (low,high).
If specified, takes precedence over data and dimension ranges.""")

colorbar = param.Boolean(default=False, doc="""
Whether to draw a colorbar.""")
Expand Down Expand Up @@ -775,6 +778,11 @@ def _norm_kwargs(self, element, ranges, opts, vdim, values=None, prefix=''):
self.handles[prefix+'color_dim'] = vdim

clim = opts.pop(prefix+'clims', None)

# check if there's an actual value (not np.nan)
if clim is None and sum((~np.isnan(v) for v in self.clim)):
clim = self.clim

if clim is None:
if not len(values):
clim = (0, 0)
Expand Down