Horizontal Scroll through chart

Hi. I want to make a graph and be able to scroll through it horizontally.
For instance, I want to be able to scroll through long gene sequences.
The closest method I found was using matplotlib’s widget (slider). But it doesn’t seem to work well with streamlit. Are there any other ways to achieve this?

Hello @wsher0901,

Plotly is an interactive graphing library that integrates well with Streamlit and can handle large datasets efficiently. You can create a Plotly chart with a horizontal scrollbar.

import streamlit as st
import plotly.express as px
import pandas as pd

df = pd.DataFrame({
    'Position': range(1, 10001),  # Example range, adjust according to your data
    'Value': np.random.randn(10000)  # Random data for demonstration
})

fig = px.line(df, x='Position', y='Value')

fig.update_layout(
    xaxis=dict(
        rangeslider=dict(
            visible=True
        ),
        type="linear"
    )
)

st.plotly_chart(fig, use_container_width=True)

Let me know if you might require any further assistance!

Kind Regards,
Sahir

P.S. Lets connect on LinkedIn!

3 Likes