Horizontal Legend Overlaps Graph

Hi, change the legend position to wherever you need:

layout=dict(
            showlegend=True,
            legend=dict(orientation='h',x=0.9, y=0.15),
            colorway=px.colors.qualitative.Pastel1,
            margin=dict(l=0, r=0, t=0, b=0),
        )