plot_dumbbell_chart()

Plots a horizontal dumbbell (range dot) chart. Best for comparing the same metric across two distinct time periods or groups — “before vs after”, “target vs actual”, “2022 vs 2023”.

Quick Example

import pandas as pd
import clean_charts as cc

df = pd.DataFrame({
    "Country": ["US", "China", "Germany", "UK", "India", "France"],
    "2010": [14.99, 6.09, 3.42, 2.48, 1.68, 2.65],
    "2023": [25.46, 17.79, 4.46, 3.33, 3.73, 3.05]
})

cc.plot_dumbbell_chart(
    data=df,
    title="GDP Growth by Country",
    subtitle="2010 vs 2023 (USD Trillions)",
    value_suffix="T",
    show_values=True
)
Dumbbell
Example output for Dumbbell.

Data Requirements

Exactly 3 columns: [Category labels, Start values, End values].

Parameters

Parameter Type Default Scope Description
datapd.DataFrameBuilt-inCommon3-column DataFrame: [Category, Start, End].
output_pathstr | NoneNoneCommonFile path to save.
widthint | NoneAutoCommonImage width in pixels.
heightint | NoneAutoCommonImage height in pixels.
aspect_ratiostr | NoneNoneCommon"square", "landscape", etc.
titlestr | NoneNoneCommonBold header text.
subtitlestr | NoneNoneCommonSecondary text.
bg_colorstr | None"#f4f3f0"CommonBackground hex color.
scale_textboolTrueCommonScale fonts proportionally.
value_suffixstr""CommonString appended to value labels.
start_colorstr"#000000"UniqueHex color for the first-series dots.
end_colorstr"#2323FF"UniqueHex color for the second-series dots.
connector_colorstrAutoUniqueHex color for the connecting line.
dot_sizefloatAutoUniqueMarker size area in points².
show_valuesboolFalseUniqueDisplay numeric value labels next to each dot.

Common Scenarios

Target vs Actual

df = pd.DataFrame({
    "Product Line": ["Software Subscriptions", "Cloud Hosting", "Hardware Sales", "Consulting"],
    "Target": [150, 120, 85, 45],
    "Actual": [142, 135, 72, 48]
})

cc.plot_dumbbell_chart(
    data=df,
    title="Q4 Revenue Performance",
    subtitle="Target vs Actual revenue by product line (in Millions)",
    value_suffix="M",
    show_values=True,
    end_color="#FD8302",
    start_color="#0241FD",
)
Dumbbell
Example output for Dumbbell.

Sentiment Shift

df = pd.DataFrame({
    "Emotion": ["Joy", "Sadness", "Anger", "Fear", "Surprise"],
    "Previous": [12, 8, 5, 3, 6],
    "Current": [15, 6, 7, 2, 9]
})

cc.plot_dumbbell_chart(
    data=df,
    title="Brand Sentiment Shift",
    connector_color="#36404A"
)
Dumbbell
Example output for Dumbbell.