How to Plot Cluster using Clustermaps class in Matplotlib

Let us suppose you have given a dataset with various variables and data points thus in order to plot the cluster map for the given data points we can use Clustermaps class.

In this example, we will import the wine quality dataset from the

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

#Import the dataset
wine_quality = pd.read_csv(‘winequality-red.csv’ delimeter=‘;’)

Let us suppose we have raw data of wine Quality datasets and associated correlation matrix data.

Now let us plot the clustermap of the data,

row_colors = wine_quality["quality"].map(dict(zip(wine_quality["quality"].unique(),"rbg")))
g = sns.clustermap(wine_quality.drop('quality',axis=1),standard_scale=1, robust=True,row_colors=row_colors, cmap='viridis')

Plot the clustermap of the following datasets,

g = sns.clustermap(corr, figsize=(10,8), z_score=1, cbar_kws={"label":"color bar"})