plot size changes when using scroll-zoom with st.plotly_chart
Author: noamgotCreated Feb 5, 2024Updated Sep 16, 2026
Labelstype:bugstatus:confirmedpriority:P3feature:st.plotly_chart
Checklist
- I have searched the existing issues for similar issues.
- I added a very descriptive title to this issue.
- I have provided sufficient information below to help reproduce this issue.
Summary
When displaying a plotly figure with zoom-scrolling enabled using st.plotly_chart, the zoom works but the axes change when scrolling.
This does not happen when:
- Zooming manually (within streamlit)
- Zooming with the scroll wheel in a standalone Plotly figure
The following GIF should demonstrate this issue:
Reproducible Code Example
import streamlit as st
import plotly.express as px
from skimage import data
import plotly.graph_objects as go
st.title("zoom scroll bug")
config = {"scrollZoom": True}
img = data.astronaut()
fig = px.imshow(img, binary_format="jpeg", binary_compression_level=0)
st.plotly_chart(fig, config=config)
fig.show(config=config)
Steps To Reproduce
Save the code above (e.g. as app.py) and run streamlit run app.py - it should open the streamlit app window (where the bug presents) and the plotly figure in a different tab (where the zoom works properly)
Expected Behavior
The figure displayed using streamlit should behave like the default plotly figure.
Current Behavior
Described above.
Is this a regression?
- Yes, this used to work in a previous version.
Debug info
- Streamlit version: 1.31.0
- Python version: 3.10
- Operating System: Linux 5.3.0-28-generic 18.04.1-Ubuntu
- Browser: Google Chrome
Additional Information
No response
Source: streamlit/streamlit