yr.bar_chart

bar_chart(
    data: object,
    x: str | None = None,
    y: str | Sequence[str] | None = None,
    colour: str | Sequence[str] | None = None,
    horizontal: bool = False,
    stack: bool = True,
) → None

Render a bar chart.

Parameters

data
type: object

Chart data; typically a pandas DataFrame.

x
type: str | None = None

Column name to use for the x-axis.

y
type: str | Sequence[str] | None = None

Column name (or names) to plot on the y-axis.

colour
type: str | Sequence[str] | None = None

Column name (or names) used to colour the bars.

horizontal
type: bool = False

Orient bars horizontally rather than vertically.

stack
type: bool = True

Stack multiple series rather than grouping side-by-side.

Examples

Compare quarterly revenue by region:

python
import pandas as pd

import yera as yr

revenue = pd.DataFrame(
    {
        "quarter": ["Q1", "Q2", "Q1", "Q2"],
        "amount": [120, 145, 98, 167],
        "region": ["North", "North", "South", "South"],
    }
)

yr.bar_chart(
    revenue,
    x="quarter",
    y="amount",
    colour="region",
    stack=False,
)