Seaborn Heatmap

  • Post category:Seaborn

In this Seaborn tutorial, you will learn how to plot a Seaborn heatmap in Python. Seaborn provides a built-in function sns.heatmap() that is used to plot a heatmap.

# import required modules
import seaborn as sns
import matplotlib.pyplot as plt

# load the dataset
var = sns.load_dataset('tips')

# create a heatmap using seaborn
sns.heatmap(var.corr(), annot = True)

# set the title of the plot
plt.title('Heatmap')

# save the plot
plt.savefig('heatmap.png')

# show the plot
plt.show()

Output:

Free resources to learn advanced skills: AiHints and CodeAllow