not necessarily a question rather a workaround I found for using Plotly charts in Streamlit apps.
When I use Plotly without any sizing guidance, legend usually covers the chart and it is oddly distorted.
Moreover, it often overlaps with the st.subheader() and other elements below it.
My workaround was to set the size of the chart twice:
- once in the Plotly object (eg,
fig.update_layout(width=1100,height=900)) - this one actually changes the size of the plot, so it’s readable
- and then in the Streamlit command (eg, `st.plotly_chart(fig,width=1100,height=900) ) - this one moves all the subsequent elements below the Plotly chart (no more overlapping!)
I’ve tried using only the Streamlit command, but it wasn’t actually changing the Plotly figure size.
I hope it helps.