8

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).

MYK
  • 1,988
  • 7
  • 30

2 Answers2

14

You can use the use_container_width argument of st.plotly_chart:

st.plotly_chart(fig, use_container_width=True)
vvvvv
  • 25,404
  • 19
  • 49
  • 81
MYK
  • 1,988
  • 7
  • 30
3
fig.update_layout(height=800)

st.plotly_chart(fig,use_container_width=True,height=800)

I used this and it worked fine. I had to use both only then it worked.