holoviz / holoviz/hvplot

Add value labels of your data to hvplot by using parameter instead of hv.Labels()

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

Description

If you want to add value labels to your data you have to overlay holoviews hv.Label() on your plot:
``` python
# import libraries
import numpy as np
import pandas as pd

import holoviews as hv
import hvplot.pandas

# create some sample data
df = pd.DataFrame({
'col1': ['bar1', 'bar2', 'bar3'],
'col2': np.random.rand(3)
})

# create your plot
plot = df.hvplot(kind='bar', x='col1', y='col2', ylim=(0, 1.2))

# create your labels separately
# kdims specifies the x and y position of your value label
# vdims specifies the column to use for the value text of your label
labels = hv.Labels(data=df, kdims=['col1', 'col2'], vdims='col2')

# use the * symbol to overlay your labels on your plot
plot * labels
```

It would be nice if you could just use something like parameter

> value_labels=True

to do this automagically right away with hvplot:
``` python
plot = df.hvplot(kind='bar', x='col1', y='col2', ylim=(0, 1.2), value_labels=True)
```

See also: [https://stackoverflow.com/questions/58900736/adding-value-labels-to-hvplot-bar](https://stackoverflow.com/questions/58900736/adding-value-labels-to-hvplot-bar)

If possible the default offset should also be a bit smart:

![Screenshot 2019-11-17 at 16 24 49](https://user-images.githubusercontent.com/7305600/69009804-85d09480-0959-11ea-9ea6-2576ec7ec23f.png)

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.