def plotmntesterrperfile(jsonfile,testfile, desc,folder): minp = np.inf minq = np.inf maxp = 0 maxq = 0 miny0 = 0 minl1 = np.inf minl2 = np.inf minlinf = np.inf pp = 0 qq =0 outfile1 = folder+"/"+desc+".299445.png" # outfile2 = folder+"/"+fno+"_index.299445.png" X_test, Y_test = readData(testfile) import json if jsonfile: with open(jsonfile, 'r') as fn: datastore = json.load(fn) from apprentice import monomial import apprentice for key in sorted(datastore.keys()): pdeg = datastore[key]['m'] qdeg = datastore[key]['n'] if(pdeg<minp): minp=pdeg if(qdeg<minq): minq=qdeg if pdeg > maxp: maxp = pdeg if qdeg > maxq: maxq = qdeg # print(minp,maxp,minq,maxq) error = np.zeros(shape = (maxp-minp+1,maxq-minq+1)) for key in sorted(datastore.keys()): pdeg = datastore[key]['m'] qdeg = datastore[key]['n'] Y_pred = np.array([],dtype=np.float64) if('scaler' in datastore[key]): rappsip = RationalApproximationSIP(datastore[key]) Y_pred = rappsip.predictOverArray(X_test) # print(Y_pred) else: structp = apprentice.monomialStructure(datastore[key]['dim'], pdeg) structq = apprentice.monomialStructure(datastore[key]['dim'], qdeg) for x in X_test: nnn = np.array(monomial.recurrence(x, structp)) p = np.array(datastore[key]['pcoeff']).dot(nnn) ddd = np.array(monomial.recurrence(x, structq)) q = np.array(datastore[key]['qcoeff']).dot(ddd) Y_pred = np.append(Y_pred,(p/q)) # print(np.c_[Y_pred,Y_test]) l1 = np.sum(np.absolute(Y_pred-Y_test)) # print(l1) l2 = np.sqrt(np.sum((Y_pred-Y_test)**2)) linf = np.max(np.absolute(Y_pred-Y_test)) x000 = np.zeros(datastore[key]['dim']) y000 = rappsip.predict(x000) print("p%d q%d %f"%(pdeg,qdeg,y000)) error[pdeg-minp][qdeg-minq] = l2 if(minl2>l2): minl2 = l2 minl1 = l1 minlinf = linf print(linf) pp = pdeg qq = qdeg miny0 = y000 # print(miiny0) import matplotlib as mpl import matplotlib.pyplot as plt mpl.rc('text', usetex = True) mpl.rc('font', family = 'serif', size=12) mpl.style.use("ggplot") cmapname = 'viridis' plt.clf() print(error) markersize = 1000 vmin = -4 vmax = 2 X,Y = np.meshgrid(range(minq,maxq+1),range(minp,maxp+1)) # plt.scatter(X,Y , marker = 's', s=markersize, c = np.ma.log10(error), cmap = cmapname, vmin=vmin, vmax=vmax, alpha = 1) plt.scatter(X,Y , marker = 's', s=markersize, c = error, cmap = cmapname, alpha = 1) plt.xlabel("$n$") plt.ylabel("$m$") plt.xlim((minq-1,maxq+1)) plt.ylim((minp-1,maxp+1)) b=plt.colorbar() # b.set_label("$\log_{10}\\left|\\left|f - \\frac{p^m}{q^n}\\right|\\right|_2$") b.set_label("$\\left|\\left|f - \\frac{p^m}{q^n}\\right|\\right|_2$") plt.title("l1=%f, l2=%f, linf=%f y0=%f found at (%d,%d)"%(minl1,minl2,minlinf,pp,qq,miny0)) plt.savefig(outfile1)
def plot2Dsurface(fname, noise, m, n, ts, fndesc, papp_or_no_papp): noisestr = "" if (noise != "0"): noisestr = "_noisepct" + noise folder = "%s%s_%s" % (fname, noisestr, ts) if not os.path.exists(folder + "/plots"): os.mkdir(folder + '/plots') if (papp_or_no_papp == "papp"): cols = 4 elif (papp_or_no_papp == "no_papp"): cols = 3 else: raise Exception("papp_or_no_papp ambiguous") box = getbox(fname) if (len(box) != 2): print("{} cannot handle dim != 2. Box len was {}".format( sys.argv[0], len(box))) sys.exit(1) npoints = 250 X_test1 = np.linspace(box[0][0], box[0][1], num=npoints) X_test2 = np.linspace(box[1][0], box[1][1], num=npoints) outx1 = "%s/plots/Cfnsurf_X_%s%s_p%s_q%s_ts%s.csv" % (folder, fname, noisestr, m, n, ts) outy = "%s/plots/Cfnsurf_Y_%s%s_p%s_q%s_ts%s.csv" % (folder, fname, noisestr, m, n, ts) rappsipfile = "%s/out/%s%s_%s_p%s_q%s_ts%s.json" % (folder, fname, noisestr, ts, m, n, ts) rappfile = "%s/outra/%s%s_%s_p%s_q%s_ts%s.json" % (folder, fname, noisestr, ts, m, n, ts) pappfile = "%s/outpa/%s%s_%s_p%s_q%s_ts%s.json" % (folder, fname, noisestr, ts, m, n, ts) if not os.path.exists(rappsipfile): print("rappsipfile %s not found" % (rappsipfile)) exit(1) if not os.path.exists(rappfile): print("rappfile %s not found" % (rappfile)) exit(1) if not os.path.exists(pappfile): print("pappfile %s not found" % (pappfile)) exit(1) rappsip = RationalApproximationSIP(rappsipfile) rapp = RationalApproximationONB(fname=rappfile) papp = PolynomialApproximation(fname=pappfile) if (rappsip.dim != 2): print("{} cannot handle dim != 2 Dim found in datastore was {}".format( sys.argv[0], rappsip.dim)) sys.exit(1) from apprentice import testData Y_test = [] for x in X_test1: for y in X_test2: Y_test.append( eval('testData.' + fname + '([' + str(x) + ',' + str(y) + '])')) Y_pred_rappsip = [] for x in X_test1: for y in X_test2: Y_pred_rappsip.append(rappsip.predict([x, y])) Y_pred_rapp = [] for x in X_test1: for y in X_test2: Y_pred_rapp.append(rapp([x, y])) Y_pred_papp = [] if (papp_or_no_papp == "papp"): for x in X_test1: for y in X_test2: Y_pred_papp.append(papp([x, y])) np.savetxt(outx1, np.stack((X_test1, X_test2), axis=1), delimiter=",") def removezeros(YYY): for num, y in enumerate(YYY): if (y == 0): # print(y, num) lower = 0 upper = len(YYY) - 1 index = num index -= 1 while (index >= 0): if (YYY[index] != 0): lower = index break index -= 1 index = num index += 1 while (index < len(YYY)): if (YYY[index] != 0): upper = index break index += 1 YYY[num] = (YYY[lower] + YYY[upper]) / 2 # print("became") # print(YYY[num], num) return YYY Y_pred_papp_diff = np.absolute(np.array(Y_pred_papp) - np.array(Y_test)) Y_pred_papp_diff = removezeros(Y_pred_papp_diff) Y_pred_rapp_diff = np.absolute(np.array(Y_pred_rapp) - np.array(Y_test)) Y_pred_rapp_diff = removezeros(Y_pred_rapp_diff) Y_pred_rappsip_diff = np.absolute( np.array(Y_pred_rappsip) - np.array(Y_test)) Y_pred_rappsip_diff = removezeros(Y_pred_rappsip_diff) np.savetxt( outy, np.stack((np.ma.log10(Y_pred_papp_diff), np.ma.log10(Y_pred_rapp_diff), np.ma.log10(Y_pred_rappsip_diff)), axis=1), delimiter=",") minyval = np.inf maxyval = 0 arr1 = np.array([min(Y_pred_rappsip), min(Y_test), min(Y_pred_rapp)]) if (papp_or_no_papp == "papp"): np.append(arr1, min(Y_pred_papp)) minyval = np.min(arr1) arr1 = np.array([max(Y_pred_rappsip), max(Y_test), max(Y_pred_rapp)]) if (papp_or_no_papp == "papp"): np.append(arr1, max(Y_pred_papp)) maxyval = np.max(arr1) import matplotlib import matplotlib.colors as colors import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.text as text cmap1 = matplotlib.cm.RdYlBu cmap3 = matplotlib.cm.seismic cmap4 = matplotlib.cm.viridis cmap5 = matplotlib.cm.coolwarm cmap6 = matplotlib.cm.magma cmap2 = 'hot' # https://stackoverflow.com/questions/16267143/matplotlib-single-colored-colormap-with-saturation from matplotlib.colors import LinearSegmentedColormap def CustomCmap(from_rgb, to_rgb): # from color r,g,b r1, g1, b1 = from_rgb # to color r,g,b r2, g2, b2 = to_rgb cdict = { 'red': ((0, r1, r1), (1, r2, r2)), 'green': ((0, g1, g1), (1, g2, g2)), 'blue': ((0, b1, b1), (1, b2, b2)) } ccc = LinearSegmentedColormap('custom_cmap', cdict) return ccc cmap7 = CustomCmap([0.00, 0.00, 0.00], [0.02, 0.75, 1.00]) cmap8 = CustomCmap([1.00, 0.42, 0.04], [0.02, 0.75, 1.00]) cmap = cmap8 fig = plt.figure(figsize=(20, 5)) ax = fig.add_subplot(1, cols, 1, projection='3d') Y_test = np.reshape(Y_test, [len(X_test1), len(X_test2)]) im1 = ax.contour3D(X_test1, X_test2, Y_test, 100, cmap=cmap, norm=colors.SymLogNorm(linthresh=0.2, linscale=0.5, vmin=minyval, vmax=maxyval), alpha=0.8) ax.set_title('(a)', fontsize=12) ax.set_xlabel('$x_1$', fontsize=12) ax.set_ylabel('$x_2$', fontsize=12) ax = fig.add_subplot(1, cols, 2, projection='3d') Y_pred_rappsip = np.reshape(Y_pred_rappsip, [len(X_test1), len(X_test2)]) im1 = ax.contour3D(X_test1, X_test2, Y_pred_rappsip, 100, cmap=cmap, norm=colors.SymLogNorm(linthresh=0.2, linscale=0.5, vmin=minyval, vmax=maxyval), alpha=0.8) ax.set_title('(b)', fontsize=12) ax.set_xlabel('$x_1$', fontsize=12) ax.set_ylabel('$x_2$', fontsize=12) ax = fig.add_subplot(1, cols, 3, projection='3d') Y_pred_rapp = np.reshape(Y_pred_rapp, [len(X_test1), len(X_test2)]) im1 = ax.contour3D(X_test1, X_test2, Y_pred_rapp, 100, cmap=cmap, norm=colors.SymLogNorm(linthresh=0.2, linscale=0.5, vmin=minyval, vmax=maxyval), alpha=0.8) ax.set_title('(c)', fontsize=12) ax.set_xlabel('$x_1$', fontsize=12) ax.set_ylabel('$x_2$', fontsize=12) if (papp_or_no_papp == "papp"): ax = fig.add_subplot(1, cols, 4, projection='3d') Y_pred_papp = np.reshape(Y_pred_papp, [len(X_test1), len(X_test2)]) im1 = ax.contour3D(X_test1, X_test2, Y_pred_papp, 100, cmap=cmap, norm=colors.SymLogNorm(linthresh=0.2, linscale=0.5, vmin=minyval, vmax=maxyval), alpha=0.8) ax.set_title('(d)', fontsize=12) ax.set_xlabel('$x_1$', fontsize=12) ax.set_ylabel('$x_2$', fontsize=12) mmm = plt.cm.ScalarMappable(cmap=cmap) mmm.set_array(Y_pred_rapp) mmm.set_clim(minyval, maxyval) b2 = fig.colorbar(mmm) b2.set_label("$\\frac{p(x_1,x_2)}{q(x_1,x_2)}$", fontsize=16) outfile = "%s/plots/P2d1f_%s%s_p%s_q%s_ts%s_%s.pdf" % ( folder, fname, noisestr, m, n, ts, papp_or_no_papp) # plt.show() plt.savefig(outfile) print("open %s;" % (outfile)) plt.close('all')
def plotoptiterationmaps(farr, noisearr, ts): import glob import json import re import json openfileStr = "" lx = "$\\log_{10}(\\alpha(M) + \\alpha(N))$" ly = "$\\log_{10}(\\Delta_{MN})$" logy = True logx = True for num, fname in enumerate(farr): box = getbox(fname) if (len(box) != 2): print("{} cannot handle dim != 2. Box len was {}".format( sys.argv[0], len(box))) sys.exit(1) npoints = 1000 X_test1 = np.linspace(box[0][0], box[0][1], num=npoints) X_test2 = np.linspace(box[1][0], box[1][1], num=npoints) for noise in noisearr: noisestr = "" if (noise != "0"): noisestr = "_noisepct" + noise folder = "%s%s_%s" % (fname, noisestr, ts) if not os.path.exists(folder): print("Folder '{}' not found.".format(folder)) sys.exit(1) if not os.path.exists(folder + "/plots"): os.mkdir(folder + '/plots') filelist = np.array(glob.glob(folder + "/out/*.json")) filelist = np.sort(filelist) for file in filelist: if file: with open(file, 'r') as fn: datastore = json.load(fn) if (datastore["dim"] != 2): print( "{} cannot handle dim != 2 Dim found in datastore was {}" .format(sys.argv[0], datastore["dim"])) sys.exit(1) if (len(datastore["iterationinfo"]) != 3): continue # if(datastore["m"] !=5 or datastore["n"] !=3): # continue print(file) maxy_pq = 0 miny_pq = np.inf maxy_q = 0 miny_q = np.inf data = {} m = datastore["m"] n = datastore["n"] outx1 = "%s/plots/Cimap_X_%s%s_p%d_q%d_ts%s.csv" % ( folder, fname, noisestr, m, n, ts) outy_pq = "%s/plots/Cimap_Y_pq_%s%s_p%d_q%d_ts%s.csv" % ( folder, fname, noisestr, m, n, ts) outy_q = "%s/plots/Cimap_Y_q_%s%s_p%d_q%d_ts%s.csv" % ( folder, fname, noisestr, m, n, ts) polex = "%s/plots/Cimap_pole_x_%s%s_p%d_q%d_ts%s.csv" % ( folder, fname, noisestr, m, n, ts) for iterno in range(3): data[iterno] = {} if file: with open(file, 'r') as fn: datastore = json.load(fn) ii = datastore["iterationinfo"] datastore['pcoeff'] = ii[iterno]['pcoeff'] datastore['qcoeff'] = ii[iterno]['qcoeff'] iro = ii[iterno]['robOptInfo']['robustArg'] iro.append(ii[iterno]['robOptInfo']['robustObj']) data[iterno]['robarg'] = iro rappsip = RationalApproximationSIP(datastore) Y_pred_pq = [] for x in X_test1: for y in X_test2: Y_pred_pq.append(rappsip.predict([x, y])) mmm = max(Y_pred_pq) # print(mmm) if (mmm > maxy_pq): maxy_pq = mmm mmm = min(Y_pred_pq) # print(mmm) if (mmm < miny_pq): miny_pq = mmm data[iterno]['Y_pred_pq'] = Y_pred_pq Y_pred_q = [] for x in X_test1: for y in X_test2: X = [x, y] X = rappsip._scaler.scale(np.array(X)) Y_pred_q.append(rappsip.denom(X)) mmm = max(Y_pred_q) # print(mmm) if (mmm > maxy_q): maxy_q = mmm mmm = min(Y_pred_q) # print(mmm) if (mmm < miny_q): miny_q = mmm data[iterno]['Y_pred_q'] = Y_pred_q np.savetxt(outx1, np.stack((X_test1, X_test2), axis=1), delimiter=",") np.savetxt(outy_pq, np.stack( (data[0]['Y_pred_pq'], data[1]['Y_pred_pq'], data[2]['Y_pred_pq']), axis=1), delimiter=",") np.savetxt(outy_q, np.stack((data[0]['Y_pred_q'], data[1]['Y_pred_q'], data[2]['Y_pred_q']), axis=1), delimiter=",") np.savetxt(polex, np.stack((data[0]['robarg'], data[1]['robarg'], data[2]['robarg']), axis=1), delimiter=",") import matplotlib import matplotlib.colors as colors import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.text as text cmap1 = matplotlib.cm.RdYlBu cmap3 = matplotlib.cm.seismic cmap4 = matplotlib.cm.viridis cmap5 = matplotlib.cm.coolwarm cmap6 = matplotlib.cm.magma cmap2 = 'hot' x1lim = (box[0][0], box[0][1]) x2lim = (box[1][0], box[1][1]) fig = plt.figure(figsize=(17, 8)) ypredmaster = [] from matplotlib.colors import LinearSegmentedColormap def CustomCmap(from_rgb, to_rgb): # from color r,g,b r1, g1, b1 = from_rgb # to color r,g,b r2, g2, b2 = to_rgb cdict = { 'red': ((0, r1, r1), (1, r2, r2)), 'green': ((0, g1, g1), (1, g2, g2)), 'blue': ((0, b1, b1), (1, b2, b2)) } ccc = LinearSegmentedColormap('custom_cmap', cdict) return ccc cmap7 = CustomCmap([0.00, 0.00, 0.00], [0.02, 0.75, 1.00]) cmap8 = CustomCmap([1.00, 0.42, 0.04], [0.02, 0.75, 1.00]) cmap = cmap8 # axarray = np.array([]) for iterno in range(3): ax = fig.add_subplot(2, 3, iterno + 1, projection='3d') min111 = min(data[iterno]['Y_pred_pq']) max111 = max(data[iterno]['Y_pred_pq']) Y_pred_pq = np.reshape( data[iterno]['Y_pred_pq'], [len(X_test1), len(X_test2)]) # im1 = ax.contour3D(X_test1, X_test2, Y_pred_pq, 100, cmap=cmap2, norm = colors.SymLogNorm(linthresh=1, linscale=1,vmin=miny_pq, vmax=maxy_pq),alpha=0.8) im1 = ax.contour3D(X_test1, X_test2, Y_pred_pq, 100, cmap=cmap, norm=colors.SymLogNorm(linthresh=0.2, linscale=0.5, vmin=miny_pq, vmax=maxy_pq), alpha=0.8) # im1 = ax.contour3D(X_test1, X_test2, Y_pred_pq, cmap=matplotlib.cm.seismic,vmin=miny_pq, vmax=maxy_pq) # axarray = np.append(axarray,ax) if (iterno == 0): ypredmaster = Y_pred_pq if (iterno == 2): mmm = plt.cm.ScalarMappable(cmap=cmap) mmm.set_array(ypredmaster) mmm.set_clim(miny_pq, maxy_pq) b1 = fig.colorbar(mmm) b1.set_label("$\\frac{p(x_1,x_2)}{q(x_1,x_2)}$", fontsize=16) # ax.set_title('Iteration: %d'%(iterno+1), fontsize = 12) ax.set_xlabel('$x_1$', fontsize=14) ax.set_ylabel('$x_2$', fontsize=14) # b1 = fig.colorbar(im1,ax=ax, shrink=0.95,extend='both') # if(iterno ==2): # b1.set_label("$\\frac{p_m(x_1,x_2)}{q_n(x_1,x_2)}$", fontsize = 14) ax.set(xlim=x1lim, ylim=x2lim) ax.view_init(60, 35) if (iterno != 2): ax.scatter(data[iterno]['robarg'][1], data[iterno]['robarg'][0], marker='*', c="black", s=333, alpha=1, zorder=1) for iterno in range(3): ax = fig.add_subplot(2, 3, iterno + 4, projection='3d') min111 = min(data[iterno]['Y_pred_pq']) max111 = max(data[iterno]['Y_pred_pq']) Y_pred_q = np.reshape( data[iterno]['Y_pred_q'], [len(X_test1), len(X_test2)]) im2 = ax.contour3D(X_test1, X_test2, Y_pred_q, cmap=cmap, norm=colors.SymLogNorm(linthresh=4, linscale=0.6, vmin=miny_q, vmax=maxy_q)) # im2 = ax.contour3D(X_test1, X_test2, Y_pred_q, cmap=cmap2,vmin=miny_q, vmax=maxy_q) # ax.set_title('Iteration: %d'%(iterno+1), fontsize = 12) ax.set_xlabel('$x_1$', fontsize=14) ax.set_ylabel('$x_2$', fontsize=14) # b2 = fig.colorbar(im2,ax=ax, shrink=0.95,extend='both') if (iterno == 0): ypredmaster = Y_pred_q if (iterno == 2): mmm = plt.cm.ScalarMappable(cmap=cmap) mmm.set_array(ypredmaster) mmm.set_clim(miny_q, maxy_q) b2 = fig.colorbar(mmm) b2.set_label("$q(x_1,x_2)$", fontsize=12) ax.view_init(60, 35) if (iterno != 2): ax.scatter(data[iterno]['robarg'][1], data[iterno]['robarg'][0], marker='*', c="black", s=333, alpha=1, zorder=1) # b2=fig.colorbar(im2,ax=ax, shrink=0.95,extend='both') # fig.suptitle("%s%s. m = %d, n = %d. trainingsize = %s "%(fname, noisestr,m,n,ts), fontsize = 18) # plt.show() # exit(1) # # cmap2='hot' # import matplotlib # import matplotlib.colors as colors # cmap1 = matplotlib.cm.RdYlBu # import matplotlib as mpl # import matplotlib.pyplot as plt # import matplotlib.text as text # fig, axarr = plt.subplots(2,3, figsize=(17,8)) # x1lim = (box[0][0]-0.5,box[0][1]+0.5) # x2lim = (box[1][0]-0.5,box[1][1]+0.5) # # if(abs(miny_pq) < abs(maxy_pq)): # # miny_pq = -abs(maxy_pq) # # maxy_pq = abs(maxy_pq) # # elif(abs(miny_pq) > abs(maxy_pq)): # # miny_pq = -abs(miny_pq) # # maxy_pq = abs(miny_pq) # # xx,yy = np.meshgrid(X_test1,X_test2) # for iterno in range(3): # min111 = min(data[iterno]['Y_pred_pq']) # max111 = max(data[iterno]['Y_pred_pq']) # # print(data[iterno]['Y_pred']) # Y_pred_pq = np.reshape(data[iterno]['Y_pred_pq'], [len(X_test1), len(X_test2)]) # # print(Y_pred_pq) # # im1 = axarr[0][iterno].pcolormesh(X_test1, X_test2, Y_pred_pq, cmap=cmap, vmin=min111, vmax=max111) # # im1 = axarr[0][iterno].pcolormesh(X_test1,X_test2, Y_pred_pq, cmap=cmap) # # im1 = axarr[0][iterno].pcolormesh(X_test1, X_test2, Y_pred_pq) # # im1 = axarr[0][iterno].pcolormesh(X_test1, X_test2, Y_pred_pq, cmap=cmap1, vmin=miny_pq, vmax=maxy_pq) # im1 = axarr[0][iterno].pcolormesh(X_test1, X_test2, Y_pred_pq, cmap=cmap1, norm = colors.SymLogNorm(linthresh=0.1, linscale=1,vmin=miny_pq, vmax=maxy_pq)) # # im1 = axarr[0][iterno].imshow(Y_pred_pq, extent=[-1, 1, -1, 1], cmap=cmap1) # # axarr[0][iterno].axis(aspect='image') # axarr[0][iterno].set_xlabel('$x_1$', fontsize = 14) # axarr[0][iterno].set_ylabel('$x_2$', fontsize = 14) # axarr[0][iterno].set(xlim=x1lim,ylim=x2lim) # if(iterno !=2): # axarr[0][iterno].scatter(data[iterno]['robarg'][1], data[iterno]['robarg'][0], marker = 'x', c = "black" ,s=50, alpha = 1) # # if(iterno ==0): # # fig.colorbar(im1) # # axarr[0][iterno].axis('tight') # # Y_pred_q = np.reshape(data[iterno]['Y_pred_q'], [len(X_test1), len(X_test2)]) # # im2 = axarr[1][iterno].contour(X_test1, X_test2, Y_pred_q, cmap=cmap2, vmin=miny_q, vmax=maxy_q) # im2 = axarr[1][iterno].pcolormesh(X_test1, X_test2, Y_pred_q, cmap=cmap1, norm = colors.SymLogNorm(linthresh=4, linscale=0.6,vmin=miny_q, vmax=maxy_q)) # axarr[1][iterno].set_xlabel('$x_1$', fontsize = 14) # axarr[1][iterno].set_ylabel('$x_2$', fontsize = 14) # axarr[1][iterno].set(xlim=x1lim,ylim=x2lim) # # if(iterno !=2): # axarr[1][iterno].scatter(data[iterno]['robarg'][1], data[iterno]['robarg'][0], marker = 'x', c = "black" ,s=50, alpha = 1) # for ax in axarr.flat: # ax.label_outer() # b1=fig.colorbar(im1,ax=axarr[0].ravel().tolist(), shrink=0.95,extend='both') # b1.set_label("$\\frac{p_m(x_1,x_2)}{q_n(x_1,x_2)}$", fontsize = 16) # b2=fig.colorbar(im2,ax=axarr[1].ravel().tolist(), shrink=0.95,extend='both') # b2.set_label("$q_n(x_1,x_2)$", fontsize = 16) # # fig.suptitle("%s%s. m = %d, n = %d. trainingsize = %s "%(fname, noisestr,m,n,ts), fontsize = 18) if not os.path.exists(folder + "/plots"): os.mkdir(folder + '/plots') outfile = "%s/plots/Pimap_%s%s_p%d_q%d_ts%s.pdf" % ( folder, fname, noisestr, m, n, ts) plt.savefig(outfile) plt.clf() openfileStr += "open " + outfile + "; " print(openfileStr) plt.close('all') print(openfileStr)