Seaborn plots not showing up
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 : import seaborn as sns In : sns.set() In : df = sns.load_dataset('iris') In : sns.pairplot(df, hue='species', size=2.5) Out: <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?
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 (
sns.plt.show()) 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 plt.show()
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