Fix Python – Seaborn plots not showing up


Asked By – rtc3po

I’m sure I’m forgetting something very simple, but I cannot get certain plots to work with Seaborn.

If I do:

import seaborn as sns

Then any plots that I create as usual with matplotlib get the Seaborn styling (with the grey grid in the background).

However, if I try to do one of the examples, such as:

In [1]: import seaborn as sns

In [2]: sns.set()

In [3]: df = sns.load_dataset('iris')

In [4]: sns.pairplot(df, hue='species', size=2.5)
Out[4]: <seaborn.axisgrid.PairGrid at 0x3e59150>

The pairplot function returns a PairGrid object, but the plot doesn’t show up.

I’m a little confused because matplotlib seems to be functioning properly, and the Seaborn styles are applied to other matplotlib plots, but the Seaborn functions don’t seem to do anything. Does anybody have any idea what might be the problem?

Now we will see solution for issue: Seaborn plots not showing up


Plots created using seaborn need to be displayed like ordinary matplotlib plots.
This can be done using the

function from matplotlib.

Originally I posted the solution to use the already imported matplotlib object from seaborn ( however this is considered to be a bad practice. Therefore, simply directly import the matplotlib.pyplot module and show your plots with

import matplotlib.pyplot as plt

If the IPython notebook is used the inline backend can be invoked to remove the necessity of calling show after each plot. The respective magic is

%matplotlib inline

This question is answered By – Jakob

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0