In [2]:
import numpy as np
import matplotlib as mpl
import pandas as pd
output = pd.read_csv('./data/Gradients.csv')
output.head()
Out[2]:
In [20]:
# Column names are strings, so need to provide a list of strings to index:
df = output[['DX_GROUP'] + [str(x) for x in range(10)]]
ASC = df['DX_GROUP'] == 2
NT = df['DX_GROUP'] == 1
G1 = df[ASC]
G2 = df[NT]
In [22]:
%matplotlib inline
## agg backend is used to create plot as a .png file
mpl.use('agg')
import matplotlib.pyplot as plt
# some plotting options
fs = 10 # fontsize
flierprops = dict(marker='o', markerfacecolor='green', markersize=12,
linestyle='none')
## combine the group collections into a list
Grd0 = [G1['0'], G2['0']]
Grd1 = [G1['1'], G2['1']]
Grd2 = [G1['2'], G2['2']]
Grd3 = [G1['3'], G2['3']]
Grd4 = [G1['4'], G2['4']]
Grd5 = [G1['5'], G2['5']]
Grd6 = [G1['6'], G2['6']]
Grd7 = [G1['7'], G2['7']]
Grd8 = [G1['8'], G2['8']]
Grd9 = [G1['9'], G2['9']]
fig, axes = plt.subplots(nrows=2, ncols=5, figsize=(6, 6), sharey=True)
axes[0, 0].boxplot(Grd0, patch_artist=True)
axes[0, 0].set_title('G0', fontsize=fs)
axes[0, 1].boxplot(Grd1, patch_artist=True)
axes[0, 1].set_title('G1', fontsize=fs)
axes[0, 2].boxplot(Grd2, patch_artist=True)
axes[0, 2].set_title('G2', fontsize=fs)
axes[0, 3].boxplot(Grd3, patch_artist=True)
axes[0, 3].set_title('G3', fontsize=fs)
axes[0, 4].boxplot(Grd4, patch_artist=True)
axes[0, 4].set_title('G4', fontsize=fs)
axes[1, 0].boxplot(Grd5, patch_artist=True)
axes[1, 0].set_title('G5', fontsize=fs)
axes[1, 1].boxplot(Grd6, patch_artist=True)
axes[1, 1].set_title('G6', fontsize=fs)
axes[1, 2].boxplot(Grd7, patch_artist=True)
axes[1, 2].set_title('G7', fontsize=fs)
axes[1, 3].boxplot(Grd8, patch_artist=True)
axes[1, 3].set_title('G8', fontsize=fs)
axes[1, 4].boxplot(Grd9, patch_artist=True)
axes[1, 4].set_title('G9', fontsize=fs)
fig.suptitle("Gradient Slopes")
fig.subplots_adjust(hspace=0.4)