Playing with Seaborn heat map palette settings in one article

Beck Moulton
4 min readJun 26, 2024

Introduction

In the previous article, we introduced how to use Seaborn to draw heat maps and detailed the control conditions in various heat maps. This article focuses on how to control the color palette in drawing heat maps.

Without further ado, let’s get started!

For example

Let’s first take a look at an example from the previous section, the code is as follows:

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


data = np.random.rand(4, 6)
heat_map = sb.heatmap(data, cmap="YlGnBu")
plt.show()

The results after running are as follows:

Observe the above code, where cmap = “YlGnBu” represents the following colors:

In fact, there are three types of palettes in the Seaborn library: sequential palettes, divergent palettes, and discrete numerical control. Next, we will explain the above three methods.

Sequential palette

When the range of data to be displayed is from low to high, the sequential color map palette can be used…

--

--

Beck Moulton

Focus on the back-end field, do actual combat technology sharing Buy me a Coffee if You Appreciate My Hard Work https://www.buymeacoffee.com/BeckMoulton