def plotScattergram(what,foldername,rs): data = {} plt.figure(1, figsize=(16,9)) if what=="OPTI": for i in range(len(rs.target_size)): name = rs.OPTIpath + str(rs.target_size[i]) + "/" + foldername + "/finalX/" tmp = getLastXData(name) tabx = [] for el in tmp.values(): for j in range(len(el)): tabx.append(el[j]) data[rs.target_size[i]] = tabx for i in range(len(rs.target_size)): ax = plt.subplot2grid((4,1), (i,0)) ax.set_xlim([-0.03,0.03]) ax.hist(data[rs.target_size[i]], 100) ax.axvline(x=rs.target_size[i]/2, c = 'r', linewidth = 3) ax.axvline(x=-rs.target_size[i]/2, c = 'r', linewidth = 3) ax.set_title(str("Hit Dispersion for Target " + str(rs.target_size[i]))) imageFolder = rs.OPTIpath + "/ImageBank/" elif what=="RBFN": name = rs.path + foldername + "/finalX/" tmp = getLastXData(name) tabx = [] for el in tmp.values(): for j in range(len(el)): tabx.append(el[j]) plt.hist(tabx, 20) for i in range(len(rs.target_size)): plt.plot([-rs.target_size[i]/2, -rs.target_size[i]]/2, [0, 20], c = 'r', linewidth = 3) plt.plot([rs.target_size[i]/2, rs.target_size[i]]/2, [0, 20], c = 'r', linewidth = 3) plt.xlabel("X (m)") plt.ylabel("Y (m)") plt.title("Hit Dispersion for "+rs.regression) imageFolder = rs.path + "/ImageBank/" checkIfFolderExists(imageFolder) plt.savefig(imageFolder+what+"_hitdisp"+foldername+".svg", bbox_inches='tight') plt.show(block = True)
def plotScattergram(what,foldername): rs = ReadSetupFile() data = {} if what=="CMAES": for i in range(len(rs.sizeOfTarget)): name = rs.CMAESpath + str(rs.sizeOfTarget[i]) + "/" + foldername + "/finalX/" tmp = getLastXData(name) tabx = [] for el in tmp.values(): for j in range(len(el)): tabx.append(el[j]) data[rs.sizeOfTarget[i]] = tabx plt.figure(1, figsize=(16,9)) for i in range(len(rs.sizeOfTarget)): ax = plt.subplot2grid((2,2), (i/2,i%2)) ax.hist(data[rs.sizeOfTarget[i]], 20) ax.plot([-rs.sizeOfTarget[i]/2, -rs.sizeOfTarget[i]]/2, [0, 500], c = 'r', linewidth = 3) ax.plot([rs.sizeOfTarget[i]/2, rs.sizeOfTarget[i]]/2, [0, 500], c = 'r', linewidth = 3) ax.set_title(str("Hit Dispersion for Target " + str(rs.sizeOfTarget[i]))) elif what=="NN": name = rs.NNpath + foldername + "/finalX/" tmp = getLastXData(name) tabx = [] for el in tmp.values(): for j in range(len(el)): tabx.append(el[j]) plt.hist(tabx, 20) for i in range(len(rs.sizeOfTarget)): plt.plot([-rs.sizeOfTarget[i]/2, -rs.sizeOfTarget[i]]/2, [0, 20], c = 'r', linewidth = 3) plt.plot([rs.sizeOfTarget[i]/2, rs.sizeOfTarget[i]]/2, [0, 20], c = 'r', linewidth = 3) plt.xlabel("X (m)") plt.ylabel("Y (m)") plt.title("Hit Dispersion for NN") plt.savefig("ImageBank/"+what+"_hitdisp"+foldername+".png", bbox_inches='tight') plt.show(block = True)
def plotHitDispersion(foldername,sizeT): rs = ReadSetupFile() name = rs.CMAESpath + sizeT + "/" + foldername + "/finalX/" data = getLastXData(name) tabx, taby = [], [] for el in data.values(): for j in range(len(el)): tabx.append(el[j]) taby.append(rs.YTarget) fig = plt.figure(1, figsize=(16,9)) plt.plot([-rs.sizeOfTarget[0]/2, rs.sizeOfTarget[0]/2], [rs.YTarget, rs.YTarget], c = 'r') plt.scatter([-rs.sizeOfTarget[0]/2, rs.sizeOfTarget[0]/2], [rs.YTarget, rs.YTarget], marker=u'|', s = 100) plt.scatter(tabx, taby, c = 'b') plt.xlabel("X (m)") plt.ylabel("Y (m)") plt.savefig("ImageBank/hit" + str(sizeT) +foldername + ".png", bbox_inches='tight') plt.show(block = True)
def plotHitDispersion(foldername,sizeT, rs): name = rs.OPTIpath + sizeT + "/" + foldername + "/finalX/" data = getLastXData(name) tabx, taby = [], [] for el in data.values(): for j in range(len(el)): tabx.append(el[j]) taby.append(rs.YTarget) plt.figure(1, figsize=(16,9)) plt.plot([-rs.target_size[0]/2, rs.target_size[0]/2], [rs.YTarget, rs.YTarget], c = 'r') plt.scatter([-rs.target_size[0]/2, rs.target_size[0]/2], [rs.YTarget, rs.YTarget], marker=u'|', s = 100) plt.scatter(tabx, taby, c = 'b') plt.xlabel("X (m)") plt.ylabel("Y (m)") imageFolder = rs.OPTIpath + sizeT +"/ImageBank/" checkIfFolderExists(imageFolder) plt.savefig(imageFolder+"hitDispersion.svg", bbox_inches='tight') plt.show(block = True)