holoviz / holoviz/hvplot

Enable the opportunity for a Legend for single data objects

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

Description

At the moment hvplot doesn't offer the opportunity to add a legend if the data only has one entry.

The example below uses pandas, but I think this is also true for xarray and maybe others.

If I plot a line plot for a DataFrame with only on column, the y label is set by the name of the column. I can overwrite the default y label, but I can't force a legend, even in the docs it says legend is true by default.

```
import pandas as pd
import hvplot.pandas

df=pd.DataFrame({'a':[1,2,3], 'b':[3,2,1]})
df[['a']].hvplot(ylabel='€', legend='bottom') + df.hvplot(ylabel='€', legend='bottom')
```

![grafik](https://github.com/user-attachments/assets/e9de85b0-fe8b-42a8-83a7-9480a01256d8)

I think it makes sense that a legend is deactivated for single column date by default, but it would be create, I a get the change to add one.

software details

```
Python version : 3.12.4 (tags/v3.12.4:8e8a4ba, Jun 6 2024, 19:30:16) [MSC v.1940 64 bit (AMD64)]
IPython version : 8.25.0
Tornado version : 6.4.1
Bokeh version : 3.4.3
BokehJS static path : C:\Users\mosc\Envs\fbpinn\Lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)
jupyter_bokeh version : 4.0.5
Operating system : Windows-10-10.0.19045-SP0
hvplot version : 0.10.0
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.