Category Breakdown Bar Chart#

A grouped bar chart that shows how each species of penguin is distributed across different islands. This example uses the penguins dataset from hvplot’s built-in sample data.

import hvplot.pandas  # noqa

df = hvplot.sampledata.penguins('pandas')
grouped = df.groupby(['species', 'island'], observed=True).size().reset_index(name='count')

grouped.hvplot.bar(
    x='species',
    y='count',
    by='island',
    title='Category Breakdown Bar Chart (Bokeh)',
    xlabel='Species',
    ylabel='Count',
)
import hvplot.pandas  # noqa
hvplot.extension('matplotlib')

df = hvplot.sampledata.penguins('pandas')
grouped = df.groupby(['species', 'island'], observed=True).size().reset_index(name='count')

grouped.hvplot.bar(
    x='species',
    y='count',
    by='island',
    title='Category Breakdown Bar Chart (Matplotlib)',
    xlabel='Species',
    ylabel='Count',
)
grouped
species island count
0 Adelie Biscoe 44
1 Adelie Dream 56
2 Adelie Torgersen 52
3 Chinstrap Dream 68
4 Gentoo Biscoe 124
This web page was generated from a Jupyter notebook and not all interactivity will work on this website.