-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathhistogram.py
52 lines (41 loc) · 1.22 KB
/
histogram.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
#! python3
# Import Libraries
import numpy as np
import pandas as pd
import matplotlib
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import mplcyberpunk
import seaborn as sns
# Cyberpunk Histogram with KDE
"""
Base graph is Seaborn distplot object with Histogram and Kernel Density Estimate Distribution
REQUIRED MODULES (outside of normal DS imports):
- mplcyberpunk
- seaborn
"""
def distplot(ax:object, series:pd.Series, cybertheme:bool=True, dropna:bool=False) -> None:
""" Plots 2D density plot visualization with histogram
Parameters
----------
ax: Axes object
series: array-like, pd.Series of a feature
data array
cybertheme: bool, optional
sets cell plt theme to "cyberpunk"
dropna: bool, optional
drops null values in series, will not be included in plot
"""
# Set Cell Plot Style to cyberpunk
if cybertheme:
plt.style.use("cyberpunk")
# Plot Series
sns.distplot(
series,
color="red",
ax=ax,
kde_kws={
"color":'white',
"shade":True,
"alpha":0.7})