import hvplot.pandas # noqa
labels
are mostly useful when overlaid on top of other plots. For instance in this case we will plot some capitals as points and then overlay (using the *
operator) labels.
import pandas as pd
df = pd.DataFrame(
{'City': ['Buenos Aires', 'Brasilia', 'Santiago', 'Bogota', 'Caracas'],
'Country': ['Argentina', 'Brazil', 'Chile', 'Colombia', 'Venezuela'],
'Latitude': [-34.58, -15.78, -33.45, 4.60, 10.48],
'Longitude': [-58.66, -47.91, -70.66, -74.08, -66.86]})
df
df.hvplot.points(x='Longitude', y='Latitude', padding=0.2, hover_cols='all', width=300) * \
df.hvplot.labels(x='Longitude', y='Latitude', text='City', text_baseline='bottom', hover=False) * \
df.hvplot.labels(x='Longitude', y='Latitude', text='Country', text_baseline='top', hover=False)