plotlystreamlit

How do you get Plotly to adjust plot size based on screen resolution in a Streamlit app?


I'm building a streamlit app with plotly graphs. However, I'm finding it hard to set a dynamic plot width in the plotly figures (I expect the app to be viewed in multiple resolutions).

Is there a way to tell plotly to use 100% (or 80%, etc.) of the width (whatever number of pixels that might be).


Solution

  • You can use the use_container_width argument of st.plotly_chart:

    st.plotly_chart(fig, use_container_width=True)