-
Notifications
You must be signed in to change notification settings - Fork 0
/
Viz_seaborn.py
55 lines (39 loc) · 1.58 KB
/
Viz_seaborn.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
def myplot(df,themes,fig_size):
'''This is a function to plot the multiple lines and boxplot of a dataframe. We are using the
pandas to read csv file and seaborn to visualize
Parameters:
===========
df = pandas.DataFrame,
theme = "Whitegrid" or "Darkgrid" # Don't forget the String sign
fig_size = tuple (length, height); default: (16, 26),
controls the figure size of the output. '''
# Importing the libraries
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Setting up the theme
sns.set_style(themes)
# lineplots
plt.figure(figsize = fig_size)
p = sns.lineplot(data = df, markers = True,)
p.set_xlabel("Datapoints", fontsize = 20)
p.set_ylabel("Number of Houses", fontsize = 20)
plt.title('Line plots of the dataframe', fontdict={"size": 20})
# Boxplots
plt.figure(figsize = fig_size)
q = sns.boxplot(data = df)
q.set_xlabel("Models", fontsize = 20)
q.set_ylabel("Number of Houses", fontsize=20)
plt.title(f'Boxplot of the dataframe', fontdict={"size": 20})
# Heatmap
plt.figure(figsize = fig_size)
sns.heatmap(df.corr(),
cmap=sns.diverging_palette(3, 3, as_cmap=True),
annot=True,
fmt='.1f',
linecolor='k',
annot_kws={"size": 9},
square=True,
linewidths=.5,
cbar_kws={"shrink": .5})
plt.title(f'Features heatmap', fontdict={"size": 20})