From 44dd4a28a7695ec075110a969697fa401fbc81de Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Fri, 18 Sep 2020 14:24:32 +0200
Subject: [PATCH] Bring plotting commands together at the end

Bring plotting commands together at the end of the main part of the script.
---
 Analysis/plot_snapshot.py | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/Analysis/plot_snapshot.py b/Analysis/plot_snapshot.py
index 4f263fc7..f571a7c7 100755
--- a/Analysis/plot_snapshot.py
+++ b/Analysis/plot_snapshot.py
@@ -230,18 +230,6 @@ if __name__ == "__main__":
         lon_mask = np.ones(len(longitude), dtype = bool)
         lat_mask = np.ones(len(latitude), dtype = bool)
 
-    plt.figure()
-    src_crs = ccrs.PlateCarree()
-    projection = ccrs.PlateCarree()
-    ##projection = ccrs.NorthPolarStereo()
-    ax = plt.axes(projection = projection)
-
-    if args.grid:
-        lon_2d, lat_2d = np.meshgrid(longitude[lon_mask], latitude[lat_mask])
-        ax.plot(lon_2d.reshape(-1), lat_2d.reshape(-1), transform = src_crs,
-                marker = "+", color = "gray", linestyle = "None")
-
-    if args.window is None: plot_grid_bb(args.shp_tr_dir, ax)
     reader_extr = shapefile.Reader(path.join(args.shp_tr_dir, "extremum"))
     reader_outer = shapefile.Reader(path.join(args.shp_tr_dir,
                                               "outermost_contour"))
@@ -273,6 +261,19 @@ if __name__ == "__main__":
         k = k1
 
     ishape_list = select_ishapes(k, k1, ishape_last, reader_extr, args.window)
+    fig = plt.figure()
+    src_crs = ccrs.PlateCarree()
+    projection = ccrs.PlateCarree()
+    ##projection = ccrs.NorthPolarStereo()
+    ax = plt.axes(projection = projection)
+
+    if args.grid:
+        lon_2d, lat_2d = np.meshgrid(longitude[lon_mask],
+                                     latitude[lat_mask])
+        ax.plot(lon_2d.reshape(-1), lat_2d.reshape(-1), transform = src_crs,
+                marker = "+", color = "gray", linestyle = "None")
+
+    if args.window is None: plot_grid_bb(args.shp_tr_dir, ax)
     snapshot(k, ax, ishape_list, reader_extr, reader_outer, reader_m_s,
              dashed = args.dashed, light = args.light)
     ax.gridlines(draw_labels = True)
-- 
GitLab