如何让 Plotly 根据 Streamlit 应用程序中的屏幕分辨率调整绘图大小?

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

我正在构建一个带有 plotly 图表的 streamlit 应用程序。但是,我发现很难在 plotly 数字中设置动态绘图宽度(我希望该应用程序可以多种分辨率查看)。

有没有办法告诉 plotly 使用宽度的 100%(或 80%,等等)(无论像素数是多少)。

您可以使用 st.plotly_chartuse_container_width 参数:

st.plotly_chart(fig, use_container_width=True)