Altair ticks default behaviour not observed by streamlit

I have an Altair plot which renders with sensible ticks in Jupyter below:

However the same plot rendered with Streamlit (below) has way too many ticks. How to change this behaviour and keep the default (jupyter) behaviour?

My code:

my_chart = alt.Chart(data).mark_line().encode(
    x='last_changed',
    y=alt.Y('state', title=data.iloc[0]['friendly_name']),
).properties(
    width=600,
    height=300
).interactive()

st.altair_chart(my_chart, width=-1)

OK solved, I needed to encode the x-axis as time:

my_chart = alt.Chart(data).mark_line().encode(
    x='last_changed:T',
...

1 Like