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

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

Open
1 task done
Azaya89 opened this issue Oct 15, 2024 · 6 comments
Open
1 task done

Comments

@Azaya89
Copy link
Contributor

Azaya89 commented Oct 15, 2024

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

hvplot_color

  • I may be interested in making a pull request to address this
@ahuang11
Copy link
Collaborator

ahuang11 commented Oct 16, 2024

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
Copy link
Contributor Author

Azaya89 commented Oct 16, 2024

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
Copy link
Contributor Author

Azaya89 commented Oct 16, 2024

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
Copy link
Collaborator

ahuang11 commented Oct 16, 2024

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
Copy link
Member

maximlt commented Oct 17, 2024

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
Copy link
Contributor Author

Azaya89 commented Oct 17, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants