holoviz / holoviz/hvplot

Fix documentation, or Implement the color option for lineplots, areaplots, and the like

Open
#1,759 0 comments 0 reactions 0 assignees View on GitHub
TRIAGE
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

#### Is your feature request related to a problem? Please describe.
See the tail end of the discussion on #652. Currently, the option `df.hvplot.line(..., color="cat_col")` where `cat_col` is a categorical column is not supported and will error:

```plaintext
holoviews.core.options.AbbreviatedException: ValueError: Mapping a dimension to the "color" style option is not supported by the Curve element using the bokeh backend. To map the "cat" dimension to the color use a groupby operation to overlay your data along the dimension.
```

This is despite `color` being listed as an option in `hvplot.help("line")`.

#### Describe the solution you'd like
To implement this request, it would be the same as the last commenter on #652.

If implementing this is not planned, I'd like the documentation to be fixed to specify that `color` does not work with `hvplot.line` and the other plots it will not work for.

#### Describe alternatives you've considered
Of course it is always possible to create your own overlays or holoviews elements. But this would be a nice high-level API.

#### Additional context
Minimal reproducible example:

```python
x = np.linspace(0, 10, 100)

df = pl.DataFrame(
{
"x": np.tile(x, 2),
"lower": np.concatenate(
[
np.sin(x) - 0.2,
np.cos(x) - 0.2,
]
),
"upper": np.concatenate(
[
np.sin(x) + 0.2,
np.cos(x) + 0.2,
]
),
"cat": np.concatenate(
[
np.repeat("A", len(x)),
np.repeat("B", len(x)),
]
),
}
)

line_df = df.select("x", "upper", "cat").rename({"upper": "y"})

# works
line_df.hvplot.scatter(
x="x",
y="y",
color="cat",
width=600,
height=300,
)

# doesn't
line_df.hvplot.line(
x="x",
y="y",
color="cat",
width=600,
height=300,
)
```

Contributor guide

Open the contributing guide

Research direction

Start by running the minimal Polars example and compare the working scatter call with the failing df.hvplot.line call. Read the discussion on #652 and inspect the implementation and help output behind hvplot.help("line") and related plots. Done means categorical color either works consistently for the requested plots or the documentation accurately excludes unsupported cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.