From 984292a844dda639eaa713ec5cf4c7fc820e7a35 Mon Sep 17 00:00:00 2001 From: corentinlger Date: Mon, 22 Apr 2024 17:18:11 +0200 Subject: [PATCH] Improve results plot page --- static/css/main.css | 7 +++++-- templates/plots.html | 2 +- web_interface.py | 15 +++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/static/css/main.css b/static/css/main.css index d0b7999..66e533d 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -86,6 +86,10 @@ h2 { margin-top: 0; } +h2.results_plots { + margin-top: 30px; +} + p { font-size: 1.1em; color: #333; @@ -212,8 +216,7 @@ input[type="submit"]:hover { /* Plotting analysis results */ .plot-img { - max-width: 25%; - height: auto; + max-width: 30%; } .intro-fig { diff --git a/templates/plots.html b/templates/plots.html index efc116e..0df1348 100644 --- a/templates/plots.html +++ b/templates/plots.html @@ -5,7 +5,7 @@ {% endblock %} {% block body %} -

Analysis figures for {{ dir_name }} experiment

+

Analysis figures for {{ dir_name }} experiment

{% for plot_name in plot_names %}

{{ plot_name }} figure :

diff --git a/web_interface.py b/web_interface.py index 49a24f0..2645b0f 100644 --- a/web_interface.py +++ b/web_interface.py @@ -169,8 +169,8 @@ def plots(dir_name): dir_path = os.path.join(results_dir, dir_name) plot_names = [f.replace('.png', '') for f in os.listdir(dir_path) if f.endswith('.png')] - # Plot the matrix elements before the other figures - plot_names.sort(key=_matrix_sort_key) + # Plot the matrix elements before the other figures if clasical experiment, and at the end if comparison + plot_names.sort(key=lambda name: _matrix_sort_key(name, comparison)) plot_paths = _get_plot_paths_dict(dir_name, plot_names, comparison) return render_template('plots.html', dir_name=dir_name, plot_names=plot_names, plot_paths=plot_paths) @@ -178,12 +178,11 @@ def plots(dir_name): # Helper functions -def _matrix_sort_key(name): - if "matrix" in name: - return (0, name) - else: - return (1, name) - +def _matrix_sort_key(name, comparison): + # Sort the matrix at the start of the array if not comparison else at the end + matrix_prio, other_figs_prio = (1, 0) if comparison else(0, 1) + return (matrix_prio, name) if "matrix" in name else (other_figs_prio, name) + def _get_plot_paths_dict(dir_name, plot_names, comparison): plot_paths = {plot_name: f"{dir_name}/{plot_name}.png" for plot_name in plot_names} return plot_paths