'Is there a solution to use seaborn with streamlit if my app is blanck using seaborn?

MacOS + streamlit + Python 3.9.

I have an issue using seaborn.

import seaborn as sns

nb_currentprovider = plt.figure(figsize=(10,6))
sns.countplot(x="current_provider",data=df_ventes)

plt.title("Répartition des ventes selon l'opérateur actuel du client", fontsize=14)
plt.xlabel("Volume de ventes", fontsize=12)
plt.ylabel("Opérateur actuel", fontsize=12);
st.pyplot(nb_currentprovider)

My app is blank, I had the same problem with matplotlib but now it is working with:

from matplotlib.backends.backend_agg import RendererAgg
_lock = RendererAgg.lock

Does a similar solution exist for seaborn?



Solution 1:[1]

Here is an example on windows 10 using seaborn.

Code
import seaborn as sns
import matplotlib.pyplot as plt
import streamlit as st 


titanic = sns.load_dataset("titanic")

fig = plt.figure(figsize=(10, 4))
sns.countplot(x="class", data=titanic)

st.pyplot(fig)

Output

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ferdy