color_key should be used in non-datashader case for colormapping
- Dominant language
- Python
- Stars
- 1.4k
- Forks
- 124
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 1
Description
This issue is one of a number that relate to datashader support of timeseries.
```
>>> hv.__version__, bokeh.__version__, ds.__version__, panel.__version__, hvplot.__version__
('1.15.1', '2.4.3', '0.14.2', '0.13.1', '0.8.1')
```
```python
>>> timestamps = [pd.Timestamp('2022-04-01 0{0}:00:00-0000'.format(hour)) for hour in range(10)]
>>> df = pd.DataFrame({'timestamp':timestamps, 'SPY':np.random.rand(10), 'NDAQ':np.random.rand(10)})
>>> melted = pd.melt(df, id_vars=['timestamp'], var_name='stock', value_name='high')
>>> melted['bond_indicator'] = melted['stock'].isin(['SPY'])
```
I noticed that I could generate a plot *with* `rasterize=True` but not without:
```
melted.hvplot.line(x='timestamp',y='high', rasterize=True, line_width=0,
by='stock', color='bond_indicator', color_key=["red", "green"], hover=True)
```

(Note, `line_width=0` is needed due to https://github.com/holoviz/datashader/issues/1133 )
Removing `rasterize=True`:

Here the fix should be made both at the hvplot and HoloViews level (I'll file an issue there as well):
1. The HoloViews `Curve` is not vectorized it is skipping the step where it colormaps the `line_color`, leaving the raw boolean values for `line_color` which causes Bokeh to choke. (https://github.com/holoviz/holoviews/issues/5479)
2. Regardless, hvplot should detect that this is categorical data (see https://github.com/holoviz/hvplot/issues/938) which means it should automatically set something like `color=hv.dim('bond_indicator').categorize({False: 'green', True: 'red'})`.
Contributor guide
Assessment
This issue has not been assessed yet.