Skip to content

Commit 2912532

Browse files
authored
Add files via upload
1 parent a95ac0b commit 2912532

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

src/GPS/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ def add_Visualization_args(parser):
204204
parser.add_argument('--font_size', type=float, default=12, help='Title size of figure')
205205
parser.add_argument('--point_size', type=float, default=1, help='Point size of figure')
206206
parser.add_argument('--fig_facecolor', type=str, default='black', help='Facecolor of figure')
207+
parser.add_argument('--fig_style', type=str, default='dark', help='Plot style of figure')
207208

208209

209210

@@ -476,6 +477,7 @@ class VisualizeConfig:
476477
font_size: float = 12
477478
point_size: float = 1
478479
fig_facecolor: str = 'black'
480+
fig_style: str = 'dark'
479481

480482

481483
@dataclass

src/GPS/visualize.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,39 @@
1010
from 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

94101
if __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

Comments
 (0)