title: This script in python 2.x worked and made multiple plots in one run. Now, in python 3.x, it only makes one plot
body: <p>I wrote this about a year ago in python 2.x. I have since switched over to 3.x, and I am not getting any errors, but as mentioned above, only one plot is being outputted, the first stdev one. If I use #%% in Spyder to make the code under ...##mean plot##... into its own cell and run the cell, it will make that plot. If I switch the order of the mean and stdev code, then it will just make the one that comes first. I have many similar scripts and they all are having the same issue.  </p>
  
  <p>Is it the indentation? I've played around with it to no avail.</p>
  
  <pre><code># -*- coding: utf-8 -*-
  """
  Created on Wed Jun 28 09:16:29 2017
  
  @author: kmiranda
  """
  
  import numpy as np 
  import matplotlib.pyplot as plt
  import mpl_toolkits.basemap as bm
  ##from ens_function import ens_data, grd_data
  from scipy.io import netcdf
  
  for date in np.arange(3,16):
      mem=0o01
  
      DTG = '201501%2.2d00' % (date)
      nfdir='/u/prob/coupled/rowley/pertobs/kmiranda/scratch/gom/ensemble/post'
      ncfn=nfdir + '/ncom_relo_gom_' + DTG + '.%3.3d'%mem + '.nc'
      nc1 = netcdf.netcdf_file(ncfn, 'r')
      lat = nc1.variables['lat'][:]
      lon = nc1.variables['lon'][:]
      dep = nc1.variables['depth'][:]
      tau = nc1.variables['tau'][:]  ## added this. it's probably not right
      water_temp = nc1.variables['water_temp']
      t0 = np.squeeze(water_temp[1,:,:,:])*1. ##I changed the 0 to 1 here
      t0[np.where(t0 == -30000)]=np.nan
  
  
  
      bbox=[262.,281.,18.,31.]
      ma = bm.Basemap(projection='merc',llcrnrlat=bbox[2],urcrnrlat=bbox[3], \
                  llcrnrlon=bbox[0],urcrnrlon=bbox[1],lat_ts=0,resolution='i')
  
  
  
      s1 = np.zeros(t0.shape)
      s2 = np.zeros(t0.shape)
  
  
  
      #del lat, lon, dep, water_temp, t0
      #nc1.close()
  
      for i in np.arange(1,33):
  
          DTG = '201501%2.2d00' % (date)
          nfdir='/u/prob/coupled/rowley/pertobs/kmiranda/scratch/gom/ensemble/post'
          ncfn=nfdir + '/ncom_relo_gom_' + DTG + '.%3.3d' %i + '.nc'
  
          nc1 = netcdf.netcdf_file(ncfn, 'r')
          water_temp = nc1.variables['water_temp']
          t0 = np.squeeze(water_temp[1,:,:,:])*1. ##I changed the 0 to 1 here
          t0[np.where(t0 == -30000)]=np.nan
          temp = np.ma.masked_invalid(np.squeeze(t0)*water_temp.scale_factor + water_temp.add_offset)
          temp.min()
          n = i  
  
          s1 = s1 + np.power(temp,2)
          s2 = s2 + temp
          s2.min()
  
  
  
      for k in np.arange(0,21,20):    
          std = np.sqrt((((n * s1)-(np.power(s2,2)))/(n**2)))
          mean = s2/n
          mean = np.squeeze(mean[k, :, :])
          std = np.squeeze(std[k, :, :])
  
  
  
          ################ stdev plot ####################
  
          x, y = np.meshgrid(lon, lat)
          p1 = ma.pcolormesh(x, y, std, shading = 'flat', \
          cmap = plt.cm.jet, latlon = True, vmin=0, vmax=0.8)
  
          c = ma.colorbar()
          #degree = u'\xb0'
          #c.set_label("C%s" % (degree))
          #m.colorbar(p1)
          ma.drawcoastlines()
          ma.fillcontinents(color='#EDE0BE')
          ma.drawparallels(np.arange(20., 30., 5.))
          ma.drawmeridians(np.arange(270., 280., 5.))
          ma.drawcoastlines(linewidth=0.25)
          ma.drawcountries(linewidth=0.25)
          plt.title('Std Temperature %s %dm' % (DTG, dep[k]))
          fig_name =nfdir + '/temp_std_z%06.1f' % dep[k] + '_ncom_relo_gom_' + DTG + '.%3.3d' % int(tau[1]) + '.png'
          plt.savefig(fig_name , dpi=200)    
          plt.show()
          plt.clf()
  
          ########### mean plot ###################
          if k == 0:
              vmin =10
              vmax = 30
          else:
              vmin = 10
              vmax = 28
  
  
          p2 = ma.pcolormesh(x, y, mean, shading = 'flat', \
          cmap=plt.cm.jet, latlon= True, vmin=vmin, vmax=vmax)
  
          c2 = plt.colorbar()
          degree = u'\xb0'
          c2.set_label("C%s" % (degree))
  
          ma.drawcoastlines()
          ma.fillcontinents(color='#EDE0BE')
          ma.drawparallels(np.arange(20., 30., 5.))
          ma.drawmeridians(np.arange(270., 280., 5.))
          ma.drawcoastlines(linewidth=0.25)
          ma.drawcountries(linewidth=0.25)
          plt.title('Mean Temperature %s %dm' % (DTG, dep[k]))
          fig_name =nfdir + '/temp_avg_z%06.1f' % dep[k] + '_ncom_relo_gom_' + DTG + '.%3.3d' % int(tau[1]) + '.png'
          plt.savefig(fig_name , dpi=200)  
          plt.show()
          plt.clf()
  </code></pre>