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.12k stars 108 forks source link

Setting `color` parameter to a hvplot.paths datashaded plot does not have any effect #1443

Open Azaya89 opened 1 week ago

Azaya89 commented 1 week ago

ALL software version info

Software Version Info ```plaintext 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

hvplot_color

ahuang11 commented 1 week ago

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

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).

Azaya89 commented 1 week ago

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

image

I'm open to adding that if it makes sense.

Azaya89 commented 1 week ago

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).

This is confusing ngl.

ahuang11 commented 1 week ago

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.

image
maximlt commented 1 week ago

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:

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.

Azaya89 commented 1 week ago

I'd find great if we could work on referencing/documenting:

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!