Skip to content

Commit

Permalink
Improve results plot page
Browse files Browse the repository at this point in the history
  • Loading branch information
corentinlger committed Apr 22, 2024
1 parent 9eb6fbd commit 984292a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 5 additions & 2 deletions static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ h2 {
margin-top: 0;
}

h2.results_plots {
margin-top: 30px;
}

p {
font-size: 1.1em;
color: #333;
Expand Down Expand Up @@ -212,8 +216,7 @@ input[type="submit"]:hover {
/* Plotting analysis results */

.plot-img {
max-width: 25%;
height: auto;
max-width: 30%;
}

.intro-fig {
Expand Down
2 changes: 1 addition & 1 deletion templates/plots.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% endblock %}

{% block body %}
<h2>Analysis figures for {{ dir_name }} experiment </h2>
<h2 class="results_plots">Analysis figures for {{ dir_name }} experiment </h2>

{% for plot_name in plot_names %}
<p>{{ plot_name }} figure :</p>
Expand Down
15 changes: 7 additions & 8 deletions web_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,21 +169,20 @@ 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)


# 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
Expand Down

0 comments on commit 984292a

Please sign in to comment.