If I compare the two plots, I notice that the zero position is for the default theme is not centered at zero but moved a bit up on the y axis and moved a bit right to the x axis. (Not sure if this is intended or a bug but it looks wrong to me)
Question: How can I set globally to use None instead of the default streamlit theme for the plots?
Alternative: How can I set the zero on both axis in the default template in the correct position?
The slight difference in the 2 plots is due to the step size of the Y-axis which is 10 for the top plot whereas the the step size is 5 for the bottom plot. More details here.
As mentioned in the blog you can use the following to use the default Altair theme:
st.altair_theme(..., theme=None)
Details on customizing the axis limits is shown in Altair’s documentation:
I believe my question was not phrased clearly enough.
It is not about the stepsize, but about the position of the 0 on the axis labels. See below the same images, but I extended with a red line the x axis to the left. In the first plot (the default streamlit theme), the line is under the 0 on the y axis, in the second plot (the None theme), the line extended axis goes through the middle of the 0.
streamlit has no method altair_theme(), it has the method altair_chart(). altair_chart() has the parameter theme, but this would mean that every plot would need to be adjusted in every plot instead of globally.
So, my questions stay the same.
Can I set globally the theme for all plots in the multipage app instead of setting the theme parameter in the altair_chart() method?
How can I modify the default streamlit theme to not misalign the zero but to center it instead as in the second plot?
Alternatively, how can I make a custom theme as copy of the standard theme and set this one as default for all plots?
I hope it is clearer now. Thank you very much for your help.
You can add those tweaks to your altair charts without losing the default theming. Look for the labelFlush property in altair.Axis to modify that misalignment.
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.