Learn Python

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Learn Matplotlib

Seaborn Introduction

Seaborn Bar Plot

Seaborn Dist plot

Seaborn Line plot

Seaborn Scatter plot

Seaborn Box plot

Seaborn Cat plot

Seaborn Reg plot

Seaborn Histogram

Seaborn Kde plot

Seaborn Count plot

Seaborn Pair plot

Seaborn Heatmap

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Learn Deep Learning

Learn MySQL

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

Seaborn heatmap

The dataset


total_bill sex time tip size day smoker
0 500.0 male lunch 30 2 sat no
1 648.0 male dinner 35 3 sat yes
2 75.0 female lunch 10 1 sat no
3 159.0 female dinner 12 4 sat yes
4 250.0 male lunch 3 3 mon no
5 222.0 female lunch 25 3 mon yes
6 356.0 male dinner 30 4 mon no
7 99.0 female lunch 5 1 mon no
8 150.0 male dinner 4 4 mon no
9 225.0 female lunch 38 4 mon no
10 478.0 female lunch 28 3 tue yes
11 320.0 male dinner 14 3 tue yes
12 300.0 male lunch 32 2 tue yes
13 520.0 male lunch 33 3 wed yes
14 367.0 male dinner 25 3 tue yes
15 277.0 female lunch 40 4 wed yes
16 100.0 female dinner 6 1 wed no
17 99.0 male dinner 40 1 wed yes
18 199.0 female lunch 35 3 wed no
19 288.0 female dinner 21 2 wed yes
20 120.0 male dinner 18 1 thu yes
21 168.0 male lunch 15 4 thu yes
22 120.0 female dinner 10 3 thu yes
23 284.0 male lunch 8 2 thu yes

How to create heatmap?

To create heatmap write module_name.heatmap(). In the bracket write parameters.

Mandatory parameter:
Dataset stored variable name

Some other parameters:

palette:palette value name. There is some fixed name for this parameter. We can use those names for different pre-build colors. Example:Accent_r, hot, inferno_r, etc.

annot:True or False.Default is False. Using this parameter we can put numbers on the heatmap

fmt="write how many decimal number you want". Using fmt we can format the number that we got using annot.
Example:fmt="".1f". This means you want one decimal number

cmap="Fixed color mixed value". This is used to change the color of heatmap like BuPu, YlGnBu, Blues, RdBu etc.

linewidth=int value.

center=int_val. Using this parameter we can set the center point of the heatmap.

vmin=int_val. Using this parameter we can set the minimum or start value of the color map.

vmax=int_val. Using this parameter we can set the maximum or end value of the color map.

Example 1:

Input
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("E\\CSV4.csv")
sns.heatmap(df)
plt.show()

Example 2:

Input
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("E\\CSV4.csv")
sns.heatmap(df,annot=True,fmt=".1f")
plt.show()

Example 3:

Input
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("E\\CSV4.csv")
sns.heatmap(df,camp="Bupu",linewidth=0.7)
plt.show()

Example 4:

Input
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("E\\CSV4.csv")
sns.heatmap(df,camp="Bupu",linewidth=0.7,center=0)
plt.show()

Example 5:

Input
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df=pd.read_csv("E\\CSV4.csv")
sns.heatmap(df,camp="Bupu",linewidth=0.7,vmin=-1, vmax=1)
plt.show()

CodersAim is created for learning and training a self learner to become a professional from beginner. While using CodersAim, you agree to have read and accepted our terms of use, privacy policy, Contact Us

© Copyright All rights reserved www.CodersAim.com. Developed by CodersAim.