From 33cbc23d5585b21cf58166e9e7fae2bb8ef37913 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Wed, 15 Mar 2023 17:24:43 +0100
Subject: [PATCH] Add save option

---
 Trajectories/plot_traj.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/Trajectories/plot_traj.py b/Trajectories/plot_traj.py
index 2b48d0ee..8f7bacf3 100755
--- a/Trajectories/plot_traj.py
+++ b/Trajectories/plot_traj.py
@@ -14,6 +14,8 @@ parser.add_argument("expanded_traj", help = "JSon file")
 parser.add_argument("e_overestim", help = "text file")
 parser.add_argument("SHPC", help = "directory")
 parser.add_argument("orientation", choices = ["Anticyclones", "Cyclones"])
+parser.add_argument("--save", metavar = "format",
+                    help = "Save file to specified format")
 args = parser.parse_args()
 
 with open(args.expanded_traj) as f:
@@ -51,4 +53,9 @@ for traj in trajectories:
 
 ax.coastlines()
 ax.gridlines(draw_labels = True)
-plt.show()
+
+if args.save:
+    plt.savefig(f"plot_traj.{args.save}")
+    print(f'Created "plot_traj.{args.save}".')
+else:
+    plt.show()
-- 
GitLab