hvplot
hvplot copied to clipboard
Enable the opportunity for a Legend for single data objects
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')
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