I love the new widget st.metric. I’ve been using to show statistical values and I’d like to use the “delta” to show a p-value.
If I control the color using delta_color, I can make values for p>0.05 be red and p<0.05 be green. I still can’t remove the up arrow which is confusing in this case.
Any tips on removing the arrow?
import streamlit as st
st.metric('x1', value=99.2, delta='p value = 0.02', delta_color='normal')
st.metric('x2', value=47.3, delta='p value = 0.07', delta_color='inverse')
Hmm that’s a use case that delta wasn’t really intended for You can hack it with some custom CSS:
import streamlit as st
st.write(
"""
<style>
[data-testid="stMetricDelta"] svg {
display: none;
}
</style>
""",
unsafe_allow_html=True,
)
st.metric('x1', value=99.2, delta='p value = 0.02', delta_color='normal')
st.metric('x2', value=47.3, delta='p value = 0.07', delta_color='inverse')
I’ll note down for v2 of st.metric that we need to find a better solution for this use case. If it’s something other people also struggling with, we can bump up the priority of it!
Great, that’s just what I was looking for, and curiously for the same application as @metasemantic. It would be wonderful if for future updates it would be possible to do some more customization to this widget. Thanks @jrieke.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.