-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplots.py
More file actions
68 lines (53 loc) · 2.12 KB
/
Copy pathplots.py
File metadata and controls
68 lines (53 loc) · 2.12 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
import pandas as pd
def plot_hist(df: pd.DataFrame, column: str, color: str) -> None:
plt.figure(figsize=(9, 7))
sns.displot(data=df, x=column, color=color, kde=True, height=7, aspect=2)
plt.title(f'Distribution of {column}', size=20, fontweight='bold')
plt.show()
def plot_dist(df: pd.DataFrame, column: str):
plt.figure(figsize=(9, 7))
sns.distplot(df).set_title(f'Distribution of {column}')
plt.show()
def plot_count(df: pd.DataFrame, column: str) -> None:
plt.figure(figsize=(12, 7))
sns.countplot(data=df, x=column)
plt.title(f'Plot count of {column}', size=20, fontweight='bold')
plt.show()
def plot_bar(df: pd.DataFrame, x_col: str, y_col: str, title: str, xlabel: str, ylabel: str) -> None:
plt.figure(figsize=(9, 7))
sns.barplot(data=df, x=x_col, y=y_col)
plt.title(title, size=20)
plt.xticks(rotation=75, fontsize=14)
plt.yticks(fontsize=14)
plt.xlabel(xlabel, fontsize=16)
plt.ylabel(ylabel, fontsize=16)
plt.show()
def plot_heatmap(df: pd.DataFrame, title: str, cbar=False) -> None:
plt.figure(figsize=(12, 7))
sns.heatmap(df, annot=True, cmap='viridis', vmin=0,
vmax=1, fmt='.2f', linewidths=.7, cbar=cbar)
plt.title(title, size=18, fontweight='bold')
plt.show()
def plot_box(df: pd.DataFrame, x_col: str, title: str) -> None:
plt.figure(figsize=(12, 7))
sns.boxplot(data=df, x=x_col)
plt.title(title, size=20)
plt.xticks(rotation=75, fontsize=14)
plt.show()
def plot_box_multi(df: pd.DataFrame, x_col: str, y_col: str, title: str) -> None:
plt.figure(figsize=(12, 7))
sns.boxplot(data=df, x=x_col, y=y_col)
plt.title(title, size=20)
plt.xticks(rotation=75, fontsize=14)
plt.yticks(fontsize=14)
plt.show()
def plot_scatter(df: pd.DataFrame, x_col: str, y_col: str, title: str, hue: str, style: str) -> None:
plt.figure(figsize=(10, 8))
sns.scatterplot(data=df, x=x_col, y=y_col, hue=hue, style=style)
plt.title(title, size=20)
plt.xticks(fontsize=14)
plt.yticks(fontsize=14)
plt.show()