Setting `color` parameter to a hvplot.paths datashaded plot does not have any effect
ALL software version info
Software Version Info
hvplot = 0.10.0
pandas = 2.2.1
Description of expected behavior and the observed behavior
Expected behavior
I expect the lines to be colored with the provided colors.
Observed behavior
The default colors are still used, ignoring the provided colors
Complete, minimal, self-contained example code that reproduces the issue
import pandas as pd
import hvplot.pandas # noqa
df = pd.DataFrame({"x": [0, 1, None, 2, 3], "y": [0, 1, None, 2, 3],
'ascending': [True, True, None, False, False]})
df.hvplot.paths('x', 'y', by='ascending', datashade=True, color=['green', 'black'])
Stack traceback and/or browser JavaScript console output
None.
Screenshots or screencasts of the bug in action
- [x] I may be interested in making a pull request to address this
color_key works
import pandas as pd
import hvplot.pandas # noqa
df = pd.DataFrame({"x": [0, 1, None, 2, 3], "y": [0, 1, None, 2, 3],
'ascending': [True, True, None, False, False]})
df.hvplot.paths('x', 'y', by='ascending', datashade=True, color_key=['green', 'black'])
However, I agree that it's not ideal to have to know the difference/experiment between color/color_key/cmap (from my understanding, color_key if datashade, cmap if c or rasterize or raster types, and color if by).
Thanks. I also noticed that trying it using holoviews code however, emits a warning. Maybe the same warning could be implemented in hvPlot?
import datashader as ds
import holoviews as hv
import pandas as pd
from holoviews.operation.datashader import datashade
hv.extension('bokeh')
df = pd.DataFrame({"x": [0, 1, None, 2, 3], "y": [0, 1, None, 2, 3],
"ascending": [True, True, None, False, False],})
plot = hv.Path(df, ["x", "y"], ["ascending"])
datashade(plot, aggregator=ds.by("ascending"), color=["black", "green"])
I'm open to adding that if it makes sense.
However, I agree that it's not ideal to have to know the difference/experiment between color/color_key/cmap (from my understanding,
color_keyifdatashade,cmapifcorrasterizeor raster types, andcolorifby).
This is confusing ngl.
Yeah I suppose a warning could be helpful, or deprecate color_key on hvplot and merge its functionality with color, but let's wait for other maintainer's opinions
cc: @hoxbro @maximlt
Seems like it's not even documented besides one usage in the docs.
Seems like it's not even documented besides one usage in the docs.
Unfortunately that's the case for a lot of features in hvPlot!
(from my understanding, color_key if datashade, cmap if c or rasterize or raster types, and color if by).
I didn't even have that kind of mapping in mind! So I don't have yet an opinion on the best course of action. I'd find great if we could work on referencing/documenting:
- all the supported use cases and usage of
color(c),cmapandcolor_key - semantical definitions of these variables (also compared to HoloViews if there are differences https://github.com/holoviz/holoviews/blob/31ee32dfbf440e459b6ffc1b1ae8e2b651e4cb84/holoviews/operation/datashader.py#L1163-L1175)
- comparison with Pandas and Xarray plot API (what parameters they expose, what they accept, list differences)
Once something like this is done, it will be way easier to make a decision, add some warning/error on inputs parsing, and maybe decide to deprecate stuff (hvPlot 1.0?). If done right we should also be able to use the info gathered to improve the documentation extensively on this front. This is work I could help you get started with @Azaya89.
I'd find great if we could work on referencing/documenting:
- all the supported use cases and usage of
color(c),cmapandcolor_key- semantical definitions of these variables (also compared to HoloViews if there are differences https://github.com/holoviz/holoviews/blob/31ee32dfbf440e459b6ffc1b1ae8e2b651e4cb84/holoviews/operation/datashader.py#L1163-L1175)
- comparison with Pandas and Xarray plot API (what parameters they expose, what they accept, list differences)
Once something like this is done, it will be way easier to make a decision, add some warning/error on inputs parsing, and maybe decide to deprecate stuff (hvPlot 1.0?). If done right we should also be able to use the info gathered to improve the documentation extensively on this front. This is work I could help you get started with @Azaya89.
Sure, I'm open to getting started on this!