Announcing Dash Bio 1.0.0 🎉 : a one-stop-shop for bioinformatics and drug development visualizations.

How to make dumbbell plots in plotly Python?

There is a tutorial of making dumbbell plots in plotly R but not python.

Being a Python user, I’m just wondering if how can it be made in Py.

Hi @verypsb,

here is one way to do it (with the example from the plotly R docs) :slight_smile:

import pandas as pd
import as px

df = pd.read_csv("")

fig = px.scatter(df, x=['Women','Men'], y='School', labels={'variable':'gender'})
fig.update_layout(title_text = "Gender earnings disparity",
    xaxis_title = "Annual Salary (in thousands)",
    margin_l = 65)
for i in range(df.shape[0]):
        x0=df['Women'].iloc[i], y0=df['School'].iloc[i], 
        x1=df['Men'].iloc[i], y1=df['School'].iloc[i],

hope this helps, Alex-


Thanks so much, @Alexboiboi. I didn’t realize the new plotly that supports add_Line, add_shapes, etc was released.

Does the documentation update to add tutorials about add customized lines?

1 Like