holoviz / hvplot

A high-level plotting API for pandas, dask, xarray, and networkx built on HoloViews
https://hvplot.holoviz.org
BSD 3-Clause "New" or "Revised" License
1.03k stars 99 forks source link

Treat boolean color values as categorical #939

Open jlstevens opened 1 year ago

jlstevens commented 1 year ago

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')
>>> 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'])

Using rasterize=True gives a colorbar when a boolean value column can only be sensibly treated as categorical

image

There is another problem here when using line_width=1 (or any non-zero) value which is a datashader issue (https://github.com/holoviz/datashader/issues/1133)

jbednar commented 1 year ago

Agreed; a Boolean value should produce a categorical legend, not a two-value colorbar.