Seaborn Pairplot assistance

Streamlit is great. I am trying to use Seaborn. The correlation graph works fine. However, I am not able to get the Pairplot to work. Do you know if this can be made to work? It is working in Jupyter Notebook. Below is the code I am using. Thanks in advance.

if st.checkbox("Seaborn Pairplot",value=True):
	import matplotlib
	import matplotlib.pyplot as plt
	import seaborn as sns
	fig = plt.figure()
	sns.pairplot(df, hue="SKU") 
	st.pyplot(fig)

df has the following types:

Year           int64
Week           int64
SKU           object
Promotion      int64
Quantity       int64
dtype: object

Hey @SXAPDX,

Welcome to the Streamlit Community :partying_face: :tada: :partying_face: :tada:

Can you screen shot the errors that you are getting when you run the st.pyplot(fig)?

Happy Streamlit-ing!
Marisa

Hi Marisa, Thanks for your quick reply. The program runs without errors and just leaves the screen blank. So no errors.

1 Like

Hey @SXAPDX !

The following snippet for Seaborn Pairplot works for me:

import streamlit as st
import seaborn as sns

penguins = sns.load_dataset("penguins")

st.title("Hello")
fig = sns.pairplot(penguins, hue="species")
st.pyplot(fig)


Translating this to your example, I’m guessing you should initialize the fig to the Seaborn declaration then display it through Streamlit :slight_smile: :

if st.checkbox("Seaborn Pairplot",value=True):
	import seaborn as sns
	fig = sns.pairplot(df, hue="SKU") 
	st.pyplot(fig)

Tell us if this does the trick!

Best,
Fanilo

2 Likes

Hi Fanilo, Appreciate your help. This does indeed work.