✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Automatically adjust the bar width with scatter marker size in plotly

I have 3 different chart types on 1 chart using plotly express. I have bar chart, scatter-plot and horizontal line graph. Is it possible to automatically adjust the bar chart with to the size of scatter plot marker size?

I looked around in the API reference and found that you can specify the width property of the bar plot using an array

bar = go.Bar(y=[1,2,3], x=[2, 4, 6], width=[1, 0.5, 1.5])

But for the scatter plot, it is not that straightforward. You also have the size property for the marker, just like the bar plot, but it doesn’t translate directly to the size of the marker. You also have the sizemode property which can be either diameter or area and the sizeref property, which I don’t really understand.

Example for scatter plot:

scatter = go.Scatter(
    y=[1, 2, 3],
    x=[2, 4, 6],
        size=[10, 50, 60],

So to answer your question, you possibly could do it using the properties that I’ve pointed out, just I don’t know if the complexity is worth it :wink: