Change direction of axis

I have 2 charts, showing data in minutes and in hours.

When I convert to hours, the x Axis, changes, so the lowest number is on top.

I simply can’t find out how to change this, and it not due to lack of searching/trying :slight_smile:

Any good ideas ?

Thanks.

#Show total deployments in minutes
st.subheader('Time saved in minutes')
total_deployments = df.set_index('datetime')
total_deployments = total_deployments.drop(columns=['revenue_impact', 'hostname', 'requester', 'type'])
st.line_chart(total_deployments)

#Show total deployments in hours
st.subheader('Time saved in Hours')
total_deployments = df.set_index('datetime')
total_deployments = total_deployments.drop(columns=['revenue_impact', 'hostname', 'requester', 'type'])
total_deployments = pd.to_datetime(total_deployments.totaltimesaved, unit='m').dt.strftime('%H:%M')
st.line_chart(total_deployments)

Hi @rhjensen79, welcome to the Streamlit community!

The short answer here is that st.line_chart makes some assumptions for you in terms of what it thinks you want. A lot of time it works well, but sometimes there are edge cases like yours.

To get full control over your plots, you can use st.altair_chart directly, which is what line_chart is based on:

https://docs.streamlit.io/en/stable/api.html?highlight=altair_chart#streamlit.altair_chart

Thanks @randyzwitch
That helped a lot.

I got It working :slight_smile:

1 Like