dugtoni

Script won't stop running

Discussion created by dugtoni on Jul 24, 2012
Latest reply on Jul 25, 2012 by JScheirer-esristaff
I have created a function which plots data.  The problem is when I run the script it doesn't stop.  I know it is probably a really easy fix.  I would really appreciate some help!  Thanks!!

import numpy as np
import matplotlib.pyplot as plt
import datetime as DT

def plotGridmetOneDay(GcmVar,GcmYear,LastYear,output):
    with open(output+"/Climate.txt") as f:
        data = np.loadtxt(f, delimiter=',', skiprows=1,
            dtype={'names': ('date', 'count'),'formats': ('S10', 'i4')} )

    
        x = [DT.datetime.strptime(key,"%j/%Y") for (key, value) in data ]
        y = [value for (key, value) in data]

        fig = plt.figure()
        ax = fig.add_subplot(111)
        ax.grid()

        fig.autofmt_xdate()

        plt.plot(x,y)
        plt.xlabel('Date')
        plt.ylabel(str(GcmVar))
        plt.title(str(GcmVar)+" "+str(GcmYear)+"-"+str(LastYear))
        plt.savefig(output+"/ClimateMap.png",bbox_inches=0)
        plt.show()
        f.close()

Outcomes