1010from GPS .config import VisualizeConfig , add_Visualization_args
1111
1212# 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 ):
1414
1515 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+
1624 # Set the background color to black
17- fig .set_facecolor ('white' )
25+ fig .set_facecolor (facecolor )
1826 ax .set_facecolor (fig_facecolor )
1927
2028 # 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' ]
2531 cmap_custom = mcolors .ListedColormap (custom_colors )
2632
2733 # Plot the results
2834 scatter = plt .scatter (space_coord .sx , space_coord .sy , c = space_coord .logp ,
2935 cmap = cmap_custom ,marker = '.' ,edgecolor = 'none' ,lw = 0 , s = point_size )
3036
3137 # 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 )
3541
3642 # Add labels and title
3743 # plt.xlabel('Sx')
3844 # plt.ylabel('Sy')
39- plt .title (title ,fontsize = font_size )
45+ plt .title (title ,fontsize = font_size , color = text_color )
4046
4147 # Remove other elements
4248 ax .set_xticks ([])
@@ -88,7 +94,8 @@ def run_Visualize(config:VisualizeConfig):
8894 text_size = config .text_size ,
8995 font_size = config .font_size ,
9096 point_size = config .point_size ,
91- fig_facecolor = config .fig_facecolor )
97+ fig_facecolor = config .fig_facecolor ,
98+ fig_style = config .fig_style )
9299
93100
94101if __name__ == '__main__' :
@@ -107,7 +114,8 @@ def run_Visualize(config:VisualizeConfig):
107114 fig_title = 'Adult Asthma' ,
108115 fig_height = 6 ,fig_wdith = 7 ,fig_dpi = 300 ,
109116 text_size = 10 ,font_size = 12 ,point_size = 1 ,
110- fig_facecolor = 'black'
117+ fig_facecolor = 'black' ,
118+ fig_style = 'dark'
111119 )
112120 else :
113121 parser = argparse .ArgumentParser (description = "Visualization the results" )
0 commit comments