Skip to content

Commit

Permalink
Fix considering plots with one y variable as categorical (#1231)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt authored Dec 21, 2023
1 parent 17ab7b3 commit a890ed9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hvplot/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ def __init__(
# Default to categorical camp if we detect categorical shading
if ((self.datashade or self.rasterize) and (self.aggregator is None or 'count_cat' in str(self.aggregator)) and
((self.by and not self.subplots) or
(isinstance(self.y, list) or (self.y is None and len(set(self.variables) - set(self.indexes)) > 1)))):
((isinstance(self.y, list) and len(self.y) > 1) or (self.y is None and len(set(self.variables) - set(self.indexes)) > 1)))):
self._style_opts['cmap'] = self._default_cmaps['categorical']
elif symmetric:
self._style_opts['cmap'] = self._default_cmaps['diverging']
Expand Down
6 changes: 6 additions & 0 deletions hvplot/tests/testoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ def test_rasterize_by(self):
assert isinstance(plot, ImageStack)
assert plot.opts["cmap"] == cc.palette['glasbey_category10']

def test_rasterize_single_y_in_list_linear_cmap(self):
# Regression, see https://github.com/holoviz/hvplot/issues/1210
plot = self.df.hvplot.line(y=['y'], rasterize=True)
opts = Store.lookup_options('bokeh', plot[()], 'style').kwargs
assert opts.get('cmap') == 'kbc_r'

def test_resample_when_error_unset_operation(self):
with pytest.raises(
ValueError,
Expand Down

0 comments on commit a890ed9

Please sign in to comment.