Matrix Plots
Let’s learn about matrix plots in seaborn.
We'll cover the following...
Seaborn’s matrix plots, such as heatmap()
, allow us to plot the data as color-encoded matrices, while clustermap()
can be used to indicate clusters within the data.
Let’s learn this with examples:
Press + to interact
# Importing required libraries and loading datasetsimport seaborn as sns# Another trick to avoid warnings and to have a cleaner notebookimport warningswarnings.filterwarnings('ignore')tips = sns.load_dataset('tips')flights = sns.load_dataset('flights')print("Tips Data")print(tips.head())print("\nFlights Data")print(flights.head())
The heatmap()
plot
The heatmap()
plot plots rectangular data as a color-encoded matrix. It’s a commonly used way of showing a matrix plot.
In order for a heatmap()
to work properly, our data should already be in a matrix form. The sns.heatmap
function just colors it in for us.
Being in the matrix form also means that the index name and the column name match, so the cell value actually indicates something that is relevant to ...