import os import matplotlib.pyplot as plt results = {} def errorfill(x, y, yerr, color=None, alpha_fill=0.3, ax=None): ax = ax if ax is not None else plt.gca() if color is None: color = ax._get_lines.color_cycle.next() ymin, ymax = yerr ax.plot(x, y, color=color) ax.fill_between(x, ymax, ymin, color=color, alpha=alpha_fill) def generate(dim, l, la = 0.992, init = 0.01, it = 1000): axis = [] resu = [] resu_bars_mini = [] resu_bars_maxi = [] NB_IT = 8 for i in range(80, 200, 25): results[i] = [] axis.append(i) mini =10 maxi = 0 for j in range(NB_IT): os.system('./main '+str(l)+" "+str(i)+ " " + str(dim) +" "+str(it)+" " + str(la)+ " "+ str(init)+ " > res"+str(dim)) r = open("res"+str(dim), "r") res = float(r.readline()) mini = min(res, mini) maxi = max(res, maxi) results[i].append(res) resu.append(sum(results[i])/NB_IT) resu_bars_mini.append(mini) resu_bars_maxi.append(maxi) resu_bars = [resu_bars_mini, resu_bars_maxi] print results print axis print resu print resu_bars #plt.errorbar(axis, resu, resu_bars, fmt='o') errorfill(axis, resu, resu_bars) dim = 3 generate(dim, 2, 0.99, 0.001, 200) generate(dim, 2, 0.99, 0.001, 600) generate(dim, 2, 0.99, 0.001, 1000) generate(dim, 2, 0.99, 0.001, 1203) generate(dim, 2, 0.99, 0.001, 1600) errorfill(axis, resu, resu_bars) plt.show()