0

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?

vvvvv
  • 25,404
  • 19
  • 49
  • 81
Elise
  • 29
  • 1
  • 5
  • Could you post a minimal reproducible code? – ferdy Apr 03 '22 at 03:46
  • @ferdy import seaborn as sns (only that) is blocking streamlit (app blank) – Elise Apr 10 '22 at 13:27
  • 2
    Since seaborn is basically just a wrapper and produces Matplotlib figures, you can show them as regular Matplotlib figures with streamlit. However I would recommend you to look into plotly or altair as they give you interactive plots. – Jakob Guldberg Aaes Nov 04 '22 at 08:26

1 Answers1

3

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

ferdy
  • 4,396
  • 2
  • 4
  • 16