Seaborn is a wrapper around Matplotlib that makes creating common statistical plots easy. The list of supported plots includes univariate and bivariate distribution plots, regression plots, and a number of methods for plotting categorical variables. The full list of plots Seaborn provides is in their API reference.
Creating graphs in Seaborn is as simple as calling the appropriate graphing function. Here is an example of creating a histogram, kernel density estimation, and rug plot for randomly generated data.
import numpy as np # numpy used to create data from plotting import seaborn as sns # common form of importing seaborn # Generate normally distributed data data = np.random.randn(1000) # Plot a histogram with both a rugplot and kde graph superimposed sns.distplot(data, kde=True, rug=True)
The style of the plot can also be controled using a declarative syntax.
# Using previously created imports and data. # Use a dark background with no grid. sns.set_style('dark') # Create the plot again sns.distplot(data, kde=True, rug=True)
As an added bonus, normal matplotlib commands can still be applied to Seaborn plots. Here's an example of adding axis titles to our previously created histogram.
# Using previously created data and style # Access to matplotlib commands import matplotlib.pyplot as plt # Previously created plot. sns.distplot(data, kde=True, rug=True) # Set the axis labels. plt.xlabel('This is my x-axis') plt.ylabel('This is my y-axis')