Skip to content

Commit a890ed9

Browse files
authored
Fix considering plots with one y variable as categorical (#1231)
1 parent 17ab7b3 commit a890ed9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

hvplot/converter.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def __init__(
609609
# Default to categorical camp if we detect categorical shading
610610
if ((self.datashade or self.rasterize) and (self.aggregator is None or 'count_cat' in str(self.aggregator)) and
611611
((self.by and not self.subplots) or
612-
(isinstance(self.y, list) or (self.y is None and len(set(self.variables) - set(self.indexes)) > 1)))):
612+
((isinstance(self.y, list) and len(self.y) > 1) or (self.y is None and len(set(self.variables) - set(self.indexes)) > 1)))):
613613
self._style_opts['cmap'] = self._default_cmaps['categorical']
614614
elif symmetric:
615615
self._style_opts['cmap'] = self._default_cmaps['diverging']

hvplot/tests/testoperations.py

+6
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ def test_rasterize_by(self):
212212
assert isinstance(plot, ImageStack)
213213
assert plot.opts["cmap"] == cc.palette['glasbey_category10']
214214

215+
def test_rasterize_single_y_in_list_linear_cmap(self):
216+
# Regression, see https://github.com/holoviz/hvplot/issues/1210
217+
plot = self.df.hvplot.line(y=['y'], rasterize=True)
218+
opts = Store.lookup_options('bokeh', plot[()], 'style').kwargs
219+
assert opts.get('cmap') == 'kbc_r'
220+
215221
def test_resample_when_error_unset_operation(self):
216222
with pytest.raises(
217223
ValueError,

0 commit comments

Comments
 (0)