10
10
from GPS .config import VisualizeConfig , add_Visualization_args
11
11
12
12
# The fun of visualization
13
- def visualize (space_coord ,plt_pth ,title ,height ,wdith ,dpi ,text_size ,font_size ,point_size ,fig_facecolor ):
13
+ def visualize (space_coord ,plt_pth ,title ,height ,wdith ,dpi ,text_size ,font_size ,point_size ,fig_facecolor , fig_style ):
14
14
15
15
fig , ax = plt .subplots (figsize = (height ,wdith ),dpi = dpi )
16
+
17
+ if (fig_style == 'dark' ):
18
+ facecolor = 'black'
19
+ text_color = 'white'
20
+ else :
21
+ facecolor = 'white'
22
+ text_color = 'black'
23
+
16
24
# Set the background color to black
17
- fig .set_facecolor ('white' )
25
+ fig .set_facecolor (facecolor )
18
26
ax .set_facecolor (fig_facecolor )
19
27
20
28
# Set the Pvalue color
21
- custom_colors = ['#313695' ,'#4575b4' ,'#74add1' ,
22
- '#abd9e9' ,'#e0f3f8' ,'#fee090' ,
23
- '#fdae61' ,'#f46d43' ,'#d73027' ,
24
- '#a50026' ]
29
+ custom_colors = ['#313695' ,'#4575b4' ,'#74add1' ,'#abd9e9' ,'#e0f3f8' ,
30
+ '#fee090' ,'#fdae61' ,'#f46d43' ,'#d73027' ,'#a50026' ]
25
31
cmap_custom = mcolors .ListedColormap (custom_colors )
26
32
27
33
# Plot the results
28
34
scatter = plt .scatter (space_coord .sx , space_coord .sy , c = space_coord .logp ,
29
35
cmap = cmap_custom ,marker = '.' ,edgecolor = 'none' ,lw = 0 , s = point_size )
30
36
31
37
# Adjust the cbar
32
- cbar = plt .colorbar (shrink = 0.80 )
33
- cbar .set_label (r'$-\log_{10}(\text{P-value})$' ,labelpad = 2 ,size = text_size ,color = 'black' )
34
- cbar .ax .tick_params (labelsize = text_size , colors = 'black' )
38
+ cbar = plt .colorbar (shrink = 0.60 , location = 'left' )
39
+ cbar .set_label (r'$-\log_{10}(\text{P-value})$' ,labelpad = 2 ,size = text_size ,color = text_color )
40
+ cbar .ax .tick_params (labelsize = text_size , colors = text_color )
35
41
36
42
# Add labels and title
37
43
# plt.xlabel('Sx')
38
44
# plt.ylabel('Sy')
39
- plt .title (title ,fontsize = font_size )
45
+ plt .title (title ,fontsize = font_size , color = text_color )
40
46
41
47
# Remove other elements
42
48
ax .set_xticks ([])
@@ -88,7 +94,8 @@ def run_Visualize(config:VisualizeConfig):
88
94
text_size = config .text_size ,
89
95
font_size = config .font_size ,
90
96
point_size = config .point_size ,
91
- fig_facecolor = config .fig_facecolor )
97
+ fig_facecolor = config .fig_facecolor ,
98
+ fig_style = config .fig_style )
92
99
93
100
94
101
if __name__ == '__main__' :
@@ -107,7 +114,8 @@ def run_Visualize(config:VisualizeConfig):
107
114
fig_title = 'Adult Asthma' ,
108
115
fig_height = 6 ,fig_wdith = 7 ,fig_dpi = 300 ,
109
116
text_size = 10 ,font_size = 12 ,point_size = 1 ,
110
- fig_facecolor = 'black'
117
+ fig_facecolor = 'black' ,
118
+ fig_style = 'dark'
111
119
)
112
120
else :
113
121
parser = argparse .ArgumentParser (description = "Visualization the results" )
0 commit comments