-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathutil.py
29 lines (23 loc) · 894 Bytes
/
util.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
import matplotlib.pyplot as plt
import seaborn as sns
from matplotlib.ticker import MaxNLocator
import matplotlib.gridspec as gridspec
import matplotlib.patches as mpatches
def plot_dist_char(df, feature, title):
# Creating a customized chart. and giving in figsize and everything.
fig = plt.figure(constrained_layout=True, figsize=(20, 15))
# Creating a grid of 3 cols and 3 rows.
grid = gridspec.GridSpec(ncols=3, nrows=3, figure=fig)
# Customizing the histogram grid.
ax1 = fig.add_subplot(grid[0, :2])
# Set the title.
ax1.set_title('Histogram')
# plot the histogram.
sns.distplot(df.loc[:, feature],
hist=True,
kde=True,
ax=ax1,
color='#e78c3c')
ax1.set(ylabel='Frequency')
ax1.xaxis.set_major_locator(MaxNLocator(nbins=20))
plt.title(f'{title}', fontsize=18)