Can’t Display Seaborn Chart in Jupyter Notebook? here’s what to do

The other day, a reader asked me the following question:

I am getting started with using Matplotlib and Seaborn on a Jupyter notebook. Trying to show a simple scatter plot but nothing shows up. What do you think i am doing wrong so no chart is displayed ?

It’s a bit hard to help without the code sample, but here are a couple of pointers as well as a simple example that you can use to troubleshoot this.

Set %matplotlib inline

In order to plot directly into your Jupyter notebook, you need to set the following swtich a=fter importing Matplotlib.

import matplotlib.pyplot as plt
%matplotlib inline

Use pyplot.show() to display your charts

Here’s a code snippet that uses the built-in Seaborn planets dataset for simplicity.

import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline

my_data = sns.load_dataset ('planets')

sns.scatterplot(x = 'mass', y ='distance', data=my_data)
plt.show()

The plt.show method will display your scatter chart:

From here you can go ahead and customize your chart such as adding titles and legends.

Hopefully this helped answer your question. Feel free to leave us additional questions in the comments below.

Leave a Comment