Black Lives Matter. Please consider donating to Black Girls Code today.

Line widths scaled by large numbers (like a bubble plot)


I have a few line plots showing time-series data and I would like to show how many users each line represents. Say each line has the following numbers of users represented: [500, 2500, 100]. Is there a way to scale the widths of the lines automatically (like a bubble plot) to show how common each trend is?

Hi @ssimontacchi sure, you can change the line width of a scatter trace as follows

import plotly.graph_objects as go
fig = go.Figure(go.Scatter(x=[1, 2], y=[2, 3], line_width=10))

then you need to define a max width and a scaling factor to map each of your traces to a given width.

1 Like