BumpChart
Rank over time, one line per series. The Bump Chart guide shows every feature on real data; this page is the contract: the function, the shape of its data, the keys style takes, and the constant each parameter accepts.
Function
datachart.charts.BumpChart
BumpChart(
data: (
list[LineDataPointAttrs]
| list[list[LineDataPointAttrs]]
),
*,
rank_by: BUMP_RANK | str | None = None,
title: str | None = None,
xlabel: str | None = None,
ylabel: str | None = None,
subtitle: str | list[str | None] | None = None,
emphasis: (
EMPHASIS | str | list[str | None] | None
) = None,
emphasis_rule: EmphasisRuleAttrs | None = None,
figsize: FIG_SIZE | tuple[float, float] | None = None,
xmin: int | float | datetime | None = None,
xmax: int | float | datetime | None = None,
ymin: int | float | None = None,
ymax: int | float | None = None,
show_labels: bool | None = None,
label_position: BUMP_LABEL_POSITION | str | None = None,
show_markers: bool | None = None,
line_curve: float | None = None,
show_legend: bool | None = None,
legend: LegendSettingAttrs | None = None,
show_grid: SHOW_GRID | str | bool | None = None,
show_values: bool | None = None,
value_format: VALUE_FORMAT | str | None = None,
value_step: int | None = None,
aspect_ratio: ASPECT_RATIO | str | None = None,
scalex: SCALE | str | None = None,
subplots: bool | None = None,
max_cols: int | None = None,
sharex: bool | None = None,
sharey: bool | None = None,
style: (
BumpStyleAttrs | list[BumpStyleAttrs | None] | None
) = None,
xticks: (
list[int | float | datetime]
| list[list[int | float | datetime]]
| None
) = None,
xticklabels: list[str] | list[list[str]] | None = None,
xtickrotate: int | list[int | None] | None = None,
xticks_format: (
VALUE_FORMAT | DATE_FORMAT | str | None
) = None,
vlines: (
VLineSettingAttrs
| list[VLineSettingAttrs]
| list[
VLineSettingAttrs
| list[VLineSettingAttrs]
| None
]
| None
) = None,
hlines: (
HLineSettingAttrs
| list[HLineSettingAttrs]
| list[
HLineSettingAttrs
| list[HLineSettingAttrs]
| None
]
| None
) = None,
vspans: (
VSpanSettingAttrs
| list[VSpanSettingAttrs]
| list[
VSpanSettingAttrs
| list[VSpanSettingAttrs]
| None
]
| None
) = None,
hspans: (
HSpanSettingAttrs
| list[HSpanSettingAttrs]
| list[
HSpanSettingAttrs
| list[HSpanSettingAttrs]
| None
]
| None
) = None,
texts: (
TextSettingAttrs
| list[TextSettingAttrs]
| list[
TextSettingAttrs | list[TextSettingAttrs] | None
]
| None
) = None,
x: str | list[str | None] | None = None,
y: str | list[str | None] | None = None
) -> plt.Figure
Creates the bump chart.
A bump chart shows rank over time: one line per series, rank 1 at the top,
a marker at every period, and the series named at the line's end in place
of a y-axis. Use it for league tables, popularity, or market-share rankings,
where the order matters more than the gaps between values. Periods may be
numbers, dates, or strings; strings draw as categories in first-seen order.
For the values themselves use LineChart;
for a single period's order use BarChart
with sort.
Examples:
>>> from datachart.charts import BumpChart
>>> figure = BumpChart(
... data=[
... [{"x": 2022, "y": 71}, {"x": 2023, "y": 64}, {"x": 2024, "y": 80}],
... [{"x": 2022, "y": 68}, {"x": 2023, "y": 75}, {"x": 2024, "y": 77}],
... [{"x": 2022, "y": 59}, {"x": 2023, "y": 70}, {"x": 2024, "y": 62}],
... ],
... subtitle=["Ljubljana", "Maribor", "Celje"],
... title="League Table",
... xlabel="Season",
... ylabel="Rank",
... )
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The data points of the series. Can be a single list of data points for one series, or a list of lists for several.
TYPE:
|
rank_by
|
How
TYPE:
|
title
|
The title of the chart.
TYPE:
|
xlabel
|
The x-axis label.
TYPE:
|
ylabel
|
The y-axis label.
TYPE:
|
subtitle
|
The subtitle(s) of the series. Used as end labels and legend labels.
TYPE:
|
emphasis
|
The emphasis role(s) for individual series, aligned like
TYPE:
|
emphasis_rule
|
A rule that highlights the series matching it and mutes the rest,
read against a summary of each series' ranks, chosen by
TYPE:
|
figsize
|
The size of the figure.
TYPE:
|
xmin
|
The minimum x-axis value.
TYPE:
|
xmax
|
The maximum x-axis value.
TYPE:
|
ymin
|
The minimum rank shown (the top of the axis).
TYPE:
|
ymax
|
The maximum rank shown (the bottom of the axis).
TYPE:
|
show_labels
|
Whether to print each series' subtitle beside its line end, in the series color. Defaults to True.
TYPE:
|
label_position
|
Which line end carries the label, a
TYPE:
|
show_markers
|
Whether to draw a marker at every period. Defaults to True.
TYPE:
|
line_curve
|
How far each segment eases between two periods, in
TYPE:
|
show_legend
|
Whether to show the legend. Defaults to on only when
TYPE:
|
legend
|
The per-figure legend setting: title, location, column count
and alignment; each field falls back to the theme. See
TYPE:
|
show_grid
|
Which grid lines to show (e.g., "both", "x", "y");
TYPE:
|
show_values
|
Whether to print each point's original
TYPE:
|
value_format
|
Format string for the value labels: a
TYPE:
|
value_step
|
Label every Nth point (
TYPE:
|
aspect_ratio
|
The aspect ratio of the axes ("auto" or "equal"). See
TYPE:
|
scalex
|
The x-axis scale (e.g., "log", "linear").
TYPE:
|
subplots
|
Whether to create separate subplots for each series; the ranks still read every series.
TYPE:
|
max_cols
|
Maximum number of columns in subplots (when subplots=True).
TYPE:
|
sharex
|
Whether to share the x-axis in subplots.
TYPE:
|
sharey
|
Whether to share the y-axis in subplots.
TYPE:
|
style
|
Style configuration(s) for the series. See
TYPE:
|
xticks
|
Custom x-axis tick positions.
TYPE:
|
xticklabels
|
Custom x-axis tick labels.
TYPE:
|
xtickrotate
|
Rotation angle for x-axis tick labels.
TYPE:
|
xticks_format
|
The x-axis tick label format: a
TYPE:
|
vlines
|
Vertical line(s) to plot.
TYPE:
|
hlines
|
Horizontal line(s) to plot, at rank positions.
TYPE:
|
vspans
|
Vertical reference band(s) to shade, between two x positions.
TYPE:
|
hspans
|
Horizontal reference band(s) to shade, between two ranks.
TYPE:
|
texts
|
Text annotation(s) to draw.
TYPE:
|
x
|
The key name in data for x-axis values (default: "x").
TYPE:
|
y
|
The key name in data for the ranked values (default: "y").
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
plt.Figure
|
The figure containing the bump chart. |
Data
Each record in data is a LineDataPointAttrs; the x and y parameters rename its keys.
Style
style takes the keys of BumpStyleAttrs. The chart also reads the shared groups it draws: value labels (ValueLabelStyleAttrs), reference lines (VLineStyleAttrs and HLineStyleAttrs), reference bands (VSpanStyleAttrs and HSpanStyleAttrs) and text annotations (TextStyleAttrs). Every key falls back to the theme, so the same keys set the default look through config.
datachart.typings.BumpStyleAttrs
Bases: TypedDict
The typing for the bump chart style.
The line takes the plot_line_* keys (color, alpha, style, zorder);
these keys set what is specific to a bump chart.
| ATTRIBUTE | DESCRIPTION |
|---|---|
plot_bump_line_width |
The line width.
TYPE:
|
plot_bump_marker |
The marker at every period.
TYPE:
|
plot_bump_marker_size |
The marker size.
TYPE:
|
plot_bump_label_padding |
The gap between a line end and its end label, in points.
TYPE:
|
Constants
The parameters that accept a constant, with the class in datachart.constants that lists its values.
| Parameter | Constant |
|---|---|
rank_by |
BUMP_RANK |
label_position |
BUMP_LABEL_POSITION |
emphasis |
EMPHASIS |
figsize |
FIG_SIZE |
legend={"location": ..., "alignment": ...} |
LEGEND_LOCATION, LEGEND_ALIGN |
show_grid |
SHOW_GRID |
value_format |
VALUE_FORMAT |
aspect_ratio |
ASPECT_RATIO |
scalex |
SCALE |
xticks_format |
VALUE_FORMAT, DATE_FORMAT |