-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubplot_rcparams.py
155 lines (142 loc) · 4.93 KB
/
subplot_rcparams.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env python3
'''
Plot a 2x2 subplot using matplotlib rc parameters
Use specific parameters for seaborn
'''
#import packages
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from statannotations.Annotator import Annotator
ex={
'axes.titlesize' : 24,
'axes.titleweight': 'bold',
'axes.labelsize' : 24,
'axes.labelweight': 'bold',
'xtick.labelsize' : 18,
'ytick.labelsize' : 18,
'boxplot.notch': False,
'axes.spines.left': True,
'axes.spines.bottom': True,
'axes.spines.top': False,
'axes.spines.right': False,
'lines.linewidth': 2.275,
'xtick.major.width': 1.3,
'ytick.major.width': 1.3,
'xtick.minor.width': 0.65,
'ytick.minor.width': 0.65,
'grid.linewidth': 1.8,
'lines.linewidth': 2.275,
'patch.linewidth': 1,
'lines.markersize': 9.1,
'lines.markeredgewidth': 0,
'xtick.major.pad': 9.1,
'ytick.major.pad': 9.1,
'ytick.left': True,
'font.family': ['sans-serif'],
'font.sans-serif': ['Arial'],
'xtick.bottom': True
}
sns.set_theme(context='talk', style='white', rc=ex)
df=pd.read_csv('/Users/jessedesimone/Desktop/data.csv')
#sns.set_context("talk")
#plt.style.use('/Users/jessedesimone/Documents/postdoc_uf/writing/ab4240_v2/scripts/desimone.mplstyle')
x='grp'
order = ['plasma-/PET-', 'plasma+/PET-', 'plasma+/PET+']
pairs=[('plasma-/PET-', 'plasma+/PET-'), ('plasma-/PET-', 'plasma+/PET+'),('plasma+/PET-', 'plasma+/PET+')]
my_cols = {'plasma-/PET-': 'cyan', 'plasma+/PET-': 'steelblue', 'plasma+/PET+': 'lightslategrey'}
#plot subplots
f, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(15,15))
'''plot ax1'''
y1='composite_gm_fw'
sns.boxplot(data=df, x=x, y=y1, order=order, palette=my_cols,
showfliers=False,
medianprops={"color": "black"},
boxprops = {'edgecolor': 'black'},
whiskerprops = {"color": "black"},
capprops = {"color": "black"},
ax=ax1)
sns.stripplot(data=df, x=x, y=y1, order=order, palette=my_cols,
size=5, jitter=True, edgecolor="black", linewidth=1,
ax=ax1)
'''set ax1 params'''
ax1.set_title(label='Grey Matter')
ax1.set_ylabel('Composite FW')
ax1.set_xlabel('')
ax1.tick_params(axis="x")
ax1.tick_params(axis="y")
annot1 = Annotator(ax1, pairs, data=df, x=x, y=y1, order=order)
annot1.configure(test=None, loc='inside')
annot1.set_pvalues([0.0325, 0.0001, 0.21])
annot1.annotate()
'''plot ax2'''
y2='composite_wm_fw'
sns.boxplot(data=df, x=x, y=y2, order=order, palette=my_cols,
showfliers=False,
medianprops={"color": "black"},
boxprops = {'edgecolor': 'black'},
whiskerprops = {"color": "black"},
capprops = {"color": "black"},
ax=ax2)
sns.stripplot(data=df, x=x, y=y2, order=order, palette=my_cols,
size=5, jitter=True, edgecolor="black", linewidth=1,
ax=ax2)
'''set ax2 params'''
ax2.set_title(label='White Matter')
ax2.set_ylabel('')
ax2.set_xlabel('')
ax2.tick_params(axis="x")
ax2.tick_params(axis="y")
annot2 = Annotator(ax2, pairs, data=df, x=x, y=y2, order=order)
annot2.configure(test=None, loc='inside')
annot2.set_pvalues([0.1131, 0.0002, 0.1577])
annot2.annotate()
'''plot ax3'''
y3='composite_gm_fat'
sns.boxplot(data=df, x=x, y=y3, order=order, palette=my_cols,
showfliers=False,
medianprops={"color": "black"},
boxprops = {'edgecolor': 'black'},
whiskerprops = {"color": "black"},
capprops = {"color": "black"},
ax=ax3)
sns.stripplot(data=df, x=x, y=y3, order=order, palette=my_cols,
size=5, jitter=True, edgecolor="black", linewidth=1,
ax=ax3)
'''set ax3 params'''
ax3.set_title(label='')
ax3.set_ylabel('Composite FAt')
ax3.set_xlabel('')
ax3.tick_params(axis="x")
ax3.tick_params(axis="y")
annot3 = Annotator(ax3, pairs, data=df, x=x, y=y3, order=order)
annot3.configure(test=None, loc='inside')
annot3.set_pvalues([0.0056, 0.84, 0.011])
annot3.annotate()
'''plot ax4'''
y4='composite_wm_fat'
sns.boxplot(data=df, x=x, y=y4, order=order, palette=my_cols,
showfliers=False,
medianprops={"color": "black"},
boxprops = {'edgecolor': 'black'},
whiskerprops = {"color": "black"},
capprops = {"color": "black"},
ax=ax4)
sns.stripplot(data=df, x=x, y=y4, order=order, palette=my_cols,
size=5, jitter=True, edgecolor="black", linewidth=1,
ax=ax4)
'''set ax4 params'''
ax4.set_title(label='')
ax4.set_ylabel('')
ax4.set_xlabel('')
ax4.set_ylim([0.475,0.6])
ax4.tick_params(axis="x")
ax4.tick_params(axis="y")
annot4 = Annotator(ax4, pairs, data=df, x=x, y=y4, order=order)
annot4.configure(test=None, loc='inside')
annot4.set_pvalues([0.0027, 0.99, 0.0254])
annot4.annotate()
#plot and save figure
plt.savefig('/Users/jessedesimone/Desktop/test.jpg', dpi=600)
plt.show()