-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBox plots.py
More file actions
60 lines (57 loc) · 1.83 KB
/
Copy pathBox plots.py
File metadata and controls
60 lines (57 loc) · 1.83 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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
plt.rcParams['figure.figsize']=(20.0,10.0)
plt.rcParams['font.family']='serif'
df = pd.read_csv("C:/Users/adm/Documents/Datasets/new dataset/heart.csv ")
df.head()
df.columns
# convert from wide to long format and reMOVE all null values
dff = df.melt(id_vars=['output'],
value_vars=['age','sex', 'cp', 'trtbps', 'chol', 'fbs', 'restecg', 'thalachh','exng', 'oldpeak', 'slp', 'caa',
'thall', 'output'],
value_name ='count')
dff.head()
# Basic PLOT
p = sns.boxplot(data=dff,x= 'variable',y='count')
# Changing the order of the categories
sns.boxplot(data=dff,
x='variable',
y='count',
order=sorted(dff.variable.unique()))
# Change orientation
sns.boxplot(data=dff,
x='count',
y='variable',
order=sorted(dff.variable.unique()),
orient = 'h')
# Desaturate
sns.boxplot(data=dff,
x='variable',
y='count',
order=sorted(dff.variable.unique()),
saturation=.25)
# Change the size of outlier marker
sns.boxplot(data=dff,
x='variable',
y='count',
order=sorted(dff.variable.unique()),
fliersize =20)
####
sns.set(rc= {"axes.facecolor":"#ccddff",
"axes.grid":False,
'axes.labelsize':30,
'figure.figsize':(20.0,10.0),
'xtick.labelsize':25,
'ytick.labelsize':20})
h= sns.boxplot(data=dff,
x='variable',
y='count',
palette='Paired',
order=sorted(dff.variable.unique()),
notch=True)
plt.xticks(rotation =45)
l = plt.xlabel('')
plt.ylabel("Results")
plt.text(5.4,200,"Box Plot", fontsize=70,color='black',fontstyle='italic')