def plot_metrics(directory_metrics, parts_directory_plot_metrics, legend): print "\t\t[ Plotting metrics... ]" for metric in metrics: for i in range(0, 2): d = directory_metrics + "/" + parts[i] + "/" + metric + "_" + parts[i] print "\tPlotting %s ..." % d if not os.path.isdir(d): print "[%s directory not found]" % d else: xlog = False ylog = False if metric in metrics_log: xlog = True ylog = True ######################## # PLOT DISTRIBUTION ######################## data_distribution = {} with open(d + "/" + metric + "_" + parts[i] + "_distribution.data", 'r') as file: for line in file: line = line.replace("\n", "").split() data_distribution[modules.extra.num(line[0])] = modules.extra.num(line[1]) title = "" xlabel = metric ylabel = "" plot_file = parts_directory_plot_metrics[i] + "/" + xlabel + "_distribution" plot_parameters = dict(marker="o", markersize=11, linewidth=0, alpha=0.5, color=colorset[0]) if data_distribution: P = Plot(plot_file, title, xlabel, ylabel, xlog, ylog, [legend]) P.plot_single(data_distribution, plot_parameters) else: print "[Impossible to plot because no distribution data]" ######################## ######################## # PLOT CDF ######################## data_reverse_cdf = {} with open(d + "/" + metric + "_" + parts[i] + "_reverse_cdf.data", 'r') as file: for line in file: line = line.replace("\n", "").split() data_reverse_cdf[modules.extra.num(line[0])] = modules.extra.num(line[1]) title = "" xlabel = metric ylabel = "" plot_file = parts_directory_plot_metrics[i] + "/" + xlabel + "_reverse_cdf" plot_parameters = dict(linestyle="-", marker="s", markersize=8, linewidth=2.5, markeredgecolor=colorset[0], color=colorset[0]) if data_reverse_cdf: P = Plot(plot_file, title, xlabel, ylabel, False, False, [legend], formatter=True) P.plot_single(data_reverse_cdf, plot_parameters) else: print "[Impossible to plot because no reverse CDF data]"