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

Fix considering plots with one y variable as categorical #1231

Merged
merged 2 commits into from
Dec 21, 2023
Merged
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
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