Horizontal Bar Chart with Labels#
A horizontal bar chart for comparing category values along the y-axis. This example uses the penguins
dataset to show average body mass per species. Labels are added as an overlay.
import hvplot.pandas # noqa
df = hvplot.sampledata.penguins('pandas')
grouped = df.groupby('species', observed=True)['body_mass_g'].mean()
grouped.hvplot.barh(
x='species',
y='body_mass_g',
xlabel='Species',
ylabel='Body Mass (g)',
legend=False,
title='Horizontal Bar Chart (Bokeh)',
width=400, height=400,
) * grouped.hvplot.labels(
x='species',
y='body_mass_g',
hover=False,
text="{body_mass_g:.0f} g ",
text_color='white',
text_align="right",
width=400, height=400,
)
This web page was generated from a Jupyter notebook and not all
interactivity will work on this website.