Creating statistical plots easily with seaborn
seaborn is a library that builds on top of Matplotlib and Pandas to provide easy-to-use statistical plotting routines. In this recipe, we give a few examples, adapted from the official documentation, of the types of statistical plot that can be created with seaborn.
How to do it...
- Let's import NumPy, Matplotlib, and seaborn:
>>> import numpy as np from scipy import stats import matplotlib.pyplot as plt import seaborn as sns %matplotlib inline
- seaborn comes with built-in datasets, which are useful when making demos. The
tips
dataset contains bills and tips for taxi journeys:>>> tips = sns.load_dataset('tips') tips
- seaborn implements easy-to-use functions to visualize the distribution of datasets. Here, we plot the histogram, Kernel Density Estimation (KDE), and a gamma distribution fit for our dataset:
>>> # We create two subplots sharing the same y axis. f, (ax1, ax2) = plt.subplots...