Reputation: 2300
I would like to modify the theme of a seaborn objects graph displayed through streamlit. However, it seems that the graph only uses the standard theme, disregarding the .theme()
part.
The following code in a ipython notebook
import seaborn.objects as so
import seaborn as sns
import pandas as pd
import numpy as np
df = pd.DataFrame({'x': np.arange(100), 'y': np.sin(np.arange(100)/10)})
theme_dict = {**sns.axes_style("darkgrid"), "grid.linestyle": "--"}
so.Plot(df, x='x', y='y').add(so.Bars()).theme(theme_dict)
while the equivalent code for streamlit:
import streamlit as st
import seaborn as sns
import seaborn.objects as so
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
def main():
fig, ax = plt.subplots(1, 1)
theme_dict = {**sns.axes_style("darkgrid"), "grid.linestyle": "--"}
df = pd.DataFrame({"x": np.arange(100), "y": np.sin(np.arange(100) / 10)})
so.Plot(df, x="x", y="y").add(so.Bars()).on(ax).theme(theme_dict).plot()
st.pyplot(fig)
if __name__ == "__main__":
main()
with streamlit run main.py
generates the following in the browser:
without the theme. It does not matter if I move the
.theme()
further up in the chain.
Any suggestion on how to do this correctly?
streamlit 1.38.0 pyhd8ed1ab_0 conda-forge
seaborn 0.13.2 hd8ed1ab_2 conda-forge
seaborn-base 0.13.2 pyhd8ed1ab_2 conda-forge
Upvotes: 0
Views: 59