From 92bc155dc6abbc30ce4c0009d7115f43bb7595ee Mon Sep 17 00:00:00 2001 From: Lionel GUEZ <guez@lmd.ens.fr> Date: Fri, 5 Feb 2021 13:03:49 +0100 Subject: [PATCH] Add option save For the test of the script in `tests.json`. Normally, we would save to pdf, but pdf format includes a date stamp. So pdf is not convenient for testing. So we include the format value in argument save and we save to png for the automated test. --- Analysis/plot_traj.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Analysis/plot_traj.py b/Analysis/plot_traj.py index 63d0c1b4..e1cdfd5e 100755 --- a/Analysis/plot_traj.py +++ b/Analysis/plot_traj.py @@ -95,6 +95,8 @@ if __name__ == "__main__": "shapefiles, with visible eddies at all dates") parser.add_argument("-l", "--label", choices = ["root", "leaf", "split", "merge"]) + parser.add_argument("-s", "--save", default = "pdf", metavar = "format", + help = "Save file to specified format") group = parser.add_mutually_exclusive_group() group.add_argument("-n", "--node", help = "Select component containing " "node, with orientation cyclo or anti", nargs = 3, @@ -171,4 +173,9 @@ if __name__ == "__main__": ax.coastlines() ax.gridlines(draw_labels = True) print("Elapsed time:", time.perf_counter() - t1, "s") - plt.show() + + if args.save: + plt.savefig(f"plot_traj.{args.save}") + print(f'Created "plot_traj.{args.save}".') + else: + plt.show() -- GitLab