From f17b73ec31f4476b380b90237204e1aae154d572 Mon Sep 17 00:00:00 2001
From: Saku Hakamaa <sajuhak@utu.fi>
Date: Thu, 29 Nov 2018 13:27:39 +0200
Subject: [PATCH] Improve plot titles

---
 ovito_overlay.py |  1 +
 vis.py           | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/ovito_overlay.py b/ovito_overlay.py
index b725ba9..3570e2a 100644
--- a/ovito_overlay.py
+++ b/ovito_overlay.py
@@ -18,6 +18,7 @@
 # ------------------------------
 import ovito
 
+
 # This user-defined function is called by OVITO to let it draw arbitrary graphics on top of the viewport.
 # It is passed a QPainter (see http://qt-project.org/doc/qt-5/qpainter.html).
 def render(painter, **args):
diff --git a/vis.py b/vis.py
index ced7329..ad93e34 100644
--- a/vis.py
+++ b/vis.py
@@ -89,8 +89,12 @@ def draw_figures(z_positions, dict_concs_mean, energy_list, frame_list, fig_rang
         plt.ylim(-1, 101)
         plt.grid()
         plt.legend()
-        plt.title('Average concentrations from frame {start} to {end}'.format(start=profile_mean_range[0],
-                                                                              end=profile_mean_range[-1]))
+        if profile_mean_range[0] == profile_mean_range[-1]:
+            title_str = 'Concentrations at frame {frame}'.format(frame=profile_mean_range[0])
+        else:
+            title_str = 'Average concentrations from frame {start} to {end}'.format(start=profile_mean_range[0],
+                                                                                    end=profile_mean_range[-1])
+        plt.title(title_str)
         figure_mean.savefig(os.path.join(out_path, 'profile_mean.pdf'))
         data_matrix = np.transpose(np.matrix(data_matrix))
         np.savetxt(os.path.join(out_path, "profile_mean.txt"), data_matrix, header=' '.join(data_header), fmt='%.6f')
@@ -103,8 +107,12 @@ def draw_figures(z_positions, dict_concs_mean, energy_list, frame_list, fig_rang
             plt.ylim(-1, 101)
             plt.grid()
             plt.legend()
-            plt.title('Average concentrations from frame {start} to {end}'.format(start=profile_mean_range[0],
-                                                                                  end=profile_mean_range[-1]))
+            if profile_mean_range[0] == profile_mean_range[-1]:
+                title_str = 'Filtered concentrations at frame {frame}'.format(frame=profile_mean_range[0])
+            else:
+                title_str = 'Filtered average concentrations from frame {start} to {end}'.format(start=profile_mean_range[0],
+                                                                                        end=profile_mean_range[-1])
+            plt.title(title_str)
             figure_mean_filtered.savefig(os.path.join(out_path, 'profile_mean_filtered.pdf'))
 
     # ------------------------------
@@ -147,8 +155,11 @@ def draw_figures(z_positions, dict_concs_mean, energy_list, frame_list, fig_rang
         def update(frame_number):
             plt.figure(figure_anim.number)
             atom_dict_concs = frame_list[frame_number]
-
-            plt.title('Concentrations at frame {frame}'.format(frame=frame_number))
+            if average_filter:
+                title_str = 'Filtered concentrations at frame {frame}'.format(frame=frame_number)
+            else:
+                title_str = 'Concentrations at frame {frame}'.format(frame=frame_number)
+            plt.title(title_str)
             for symbol, line in lines:
                 data = atom_dict_concs[symbol]
                 if average_filter:
@@ -433,5 +444,6 @@ if __name__ == '__main__':
                      arguments.average_filter,
                      multi_path)
 
+        # TODO: write average lattice creation, simulation time
         multi_report_file.close()
         print("OK")
-- 
GitLab