def create_data_files(): i_d = 0 for r_ev in [0.01,0.1,1.0]: for r_zeros in [0.1,0.9,0.98]: i_d += 1 fn = 'performance_nr.{}.dat'.format(i_d) !./build/arpaca_performance_plot_nr 100 1000 40 10 $r_ev $r_zeros > $fn # Takes a very long time # create_data_files() import re def read_data_file(filename): f = open(filename) s = f.read() f.close() n_req = None r_ev = None r_zeros = None d = None m = re.search(r'n_rep=(.+)$',s,re.MULTILINE) if m: n_rep = int(m.group(1)) m = re.search(r'r_ev=(.+)$',s,re.MULTILINE) if m: r_ev = float(m.group(1)) m = re.search(r'r_zeros=(.+)$',s,re.MULTILINE) if m: r_zeros = float(m.group(1)) d = np.loadtxt(filename) return (n_rep,r_ev,r_zeros,d) def subplot_data_file(p, filename): n_rep,r_ev,r_zeros,d = read_data_file(filename) p.plot(d[:,0],d[:,1],label='ARPACK') p.plot(d[:,0],d[:,2],label='Eigen') p.plot(d[:,0],d[:,3],label='NR') p.set_xlabel('matrix dimension') p.set_ylabel('time (s)') p.legend(loc='upper left') #p.set_xscale('log') #p.set_yscale('log') #if r_ev == 1.0: # p.set_ylim((0,300)) p.text(0.98,0.98, '$r_{{ev}} = {}$\n$r_{{zeros}} = {}$'.format(r_ev,r_zeros), fontsize='12', verticalalignment='top', horizontalalignment='right', transform=p.transAxes) %matplotlib inline import matplotlib.gridspec as gridspec rows = 3 cols = 3 fig = plt.figure(figsize=(cols*5,rows*5)) #gs = gridspec.GridSpec(rows,cols) i_p = 0 for i in range(1,10): i_p += 1 p = fig.add_subplot(rows, cols, i_p) #p = fig.add_subplot(gs[i_p%4,i_p/4]) subplot_data_file(p, 'performance_nr.{}.dat'.format(i)) def subplot_chris(p,xlim=None,ylim=None): # columns are: N NRg++4.1.2 Arpack4.1.2 Eigen4.1.2 NR4.8.2 Eigen4.8.2 filename = 'performance_chris.dat' d = np.loadtxt(filename) p.plot(d[:,0],d[:,2],label='ARPACK G++ 4.1') p.plot(d[:,0],d[:,3],label='Eigen G++ 4.1') p.plot(d[:,0],d[:,5],label='Eigen G++ 4.8') p.plot(d[:,0],d[:,1],label='NR G++ 4.1') p.plot(d[:,0],d[:,4],label='NR G++ 4.8') p.set_xlabel('matrix dimension') p.set_ylabel('time (s)') p.legend(loc='upper left') if xlim: p.set_xlim(xlim) if ylim: p.set_ylim(ylim) rows = 1 cols = 2 fig = plt.figure(figsize=(cols*5,rows*5)) i_p = 0 i_p += 1 p = fig.add_subplot(rows, cols, i_p) subplot_chris(p,(0,1000),(0,25)) i_p += 1 p = fig.add_subplot(rows, cols, i_p) subplot_chris(p)