Skip to content

Commit

Permalink
fix: fix labels of box plots and improve the charts readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mmamica committed Nov 28, 2023
1 parent 54b6978 commit 39ce144
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion scripts/cli_scripts/plot_comparative_boxcharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,28 @@ def execute():
for column, condition in
filtering_criteria.items()),
axis=1)]
filtered_df = filtered_df.sort_values(by=val['x_axis'])

color_discrete_map = {0: '#4682B4', 1: '#E97451'}
if "dependencies" in filtered_df.columns:
fig = px.box(filtered_df, x=val['x_axis'], y="num_significant_findings", color="dependencies")
fig = px.box(filtered_df, x=val['x_axis'], y="num_significant_findings", color="dependencies", color_discrete_map=color_discrete_map)
else:
fig = px.box(filtered_df, x=val['x_axis'], y="num_significant_findings")

y_title = "Number of significant findings"
x_title_map = {"alpha": "Alpha", "multipletest_correction_type": "Multiple testing correction", "statistical_test": "Statistical test", "bin_size_ratio": "Bin size ratio", "correlation_strength": "Correlation strength", "n_sites": "Number of sites", "n_observations": "Number of observations" }
fig.update_xaxes(type='category')
fig.update_layout(
legend=dict(font=dict(size=18)),
xaxis=dict(title=dict(text=x_title_map[val['x_axis']], font=dict(size=22)), tickfont=dict(size=18)),
yaxis=dict(title=dict(text=y_title, font=dict(size=22)), tickfont=dict(size=18), range=[0, 2500])
)

fig.write_html(os.path.join(args.output_dir, f"{key}.html"))

png_file_path = os.path.join(args.output_dir, f"{key}.png")
fig.write_image(png_file_path, height=900, width=900)


def without(d, key):
new_d = d.copy()
Expand Down
6 changes: 3 additions & 3 deletions scripts/cli_scripts/plot_histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def execute():
title_pad=dict(b=200),
margin=dict(t=250),
xaxis=dict(title='Number of false findings', tickvals=custom_tick_labels, ticktext=custom_tick_labels, titlefont=dict(size=26), tickfont=dict(size=22)),
yaxis=dict(title='Number of datasets', titlefont=dict(size=26), tickfont=dict(size=22))
yaxis=dict(title='Number of datasets', titlefont=dict(size=26), tickfont=dict(size=22), range=[0, 450])
)
else:
layout = go.Layout(
xaxis=dict(title='Number of false findings', tickvals=custom_tick_labels, ticktext=custom_tick_labels, titlefont=dict(size=26), tickfont=dict(size=22)),
yaxis=dict(title='Number of datasets', titlefont=dict(size=26), tickfont=dict(size=22))
yaxis=dict(title='Number of datasets', titlefont=dict(size=26), tickfont=dict(size=22), range=[0, 450])
)

fig = go.Figure(data=[hist_trace], layout=layout)
fig.write_image(f"{args.output_dir}/{row['config_id']}.png", height=900, width=700)
fig.write_image(f"{args.output_dir}/{row['config_id']}.png", height=900, width=900)

0 comments on commit 39ce144

Please sign in to comment.