def histogram_plot(experiment_log_dir, plot_spec_string, output_filename, has_legend, x_limit, verbose): queries = [ plot_utils.plot_spec_string_to_query(plot_spec_string, 0, "HIST")] plot_data = metaprogram_utils.process_queries( queries, experiment_log_dir, verbose) if "plot_points" not in plot_data: warnings.warn("No data to plot!") return histogram_data = plot_data["plot_points"][0] cumulative_histogram = {} layout = PlotLayout() layout.dpi = 250 for stat_name in histogram_data: plot = Plot() plot.setTitle(stat_name) if has_legend: plot.hasLegend(labelSize=8) if x_limit is not None: plot.setXLimits(0, x_limit) style_plot(plot, stat_name) for key, points in sorted(histogram_data[stat_name].items()): for size, count in itertools.izip(points["bin"], points["count"]): if size not in cumulative_histogram: cumulative_histogram[size] = 0 cumulative_histogram[size] += count line = Line() line.stepFunction("pre") line.label = str(key) line.xValues = points["bin"] line.yValues = points["count"] plot.add(line) layout.addPlot(plot) cumulative_plot = Plot() if x_limit is not None: cumulative_plot.setXLimits(0, x_limit) cumulative_plot.setTitle("Cumulative Histogram for " + stat_name) style_plot(cumulative_plot, stat_name) line = Line() line.stepFunction("pre") line.xValues = sorted(cumulative_histogram.keys()) line.yValues = [cumulative_histogram[key] for key in line.xValues] cumulative_plot.add(line) layout.addPlot(cumulative_plot) layout.save(output_filename)
def constructImage(self): scatter = Scatter() scatter.label="Hooray dots with vlines!" scatter.xValues = [ 7, 6, 3, 5, 7, 6, 1, 1, 6, 5, 8, 6, 7, 8, 0, 2, 9, 3, 9, 5, 4, 5, 0, 0, 2, 3, 1, 4, 1, 3, 3, 8, 1, 5, 2, 6, 0, 3, 5, 1, 4, 9, 5, 1, 9, 9, 9, 7, 6, 5, 8, 6, 0, 2, 6, 9, 2, 5, 6, 9, 7, 8, 7, 6, 5, 9, 9, 2, 4, 9, 0, 1, 1, 1, 6, 4, 5, 8, 9, 1, 2, 1, 4, 5, 9, 7, 4, 9, 2, 9, 2, 5, 2, 2, 0, 2, 1, 9, 3, 6] scatter.yValues = [ 2, 5, 9, 5, 9, 3, 6, 1, 6, 0, 0, 6, 2, 5, 3, 9, 2, 7, 6, 2, 3, 1, 9, 9, 5, 2, 9, 0, 2, 3, 0, 2, 5, 5, 8, 4, 1, 9, 8, 6, 1, 6, 9, 2, 4, 9, 2, 8, 1, 1, 2, 1, 0, 6, 3, 4, 2, 5, 6, 8, 6, 9, 0, 6, 8, 6, 8, 1, 6, 2, 2, 3, 6, 2, 2, 2, 0, 2, 4, 6, 8, 5, 1, 4, 2, 3, 5, 3, 1, 0, 6, 0, 1, 6, 8, 9, 3, 9, 3, 7] vline1 = VLine() vline1.xValues = [2,8] vline1.color = 'CornflowerBlue' vline2 = VLine() vline2.xValues = [1,9] vline2.color = 'GoldenRod' plot = Plot() plot.hasLegend() plot.add(scatter) plot.add(vline1) plot.add(vline2) plot.save(self.imageName)
def constructImage(self): scatter = Scatter() scatter.label = "Hooray dots with vlines!" scatter.xValues = [ 7, 6, 3, 5, 7, 6, 1, 1, 6, 5, 8, 6, 7, 8, 0, 2, 9, 3, 9, 5, 4, 5, 0, 0, 2, 3, 1, 4, 1, 3, 3, 8, 1, 5, 2, 6, 0, 3, 5, 1, 4, 9, 5, 1, 9, 9, 9, 7, 6, 5, 8, 6, 0, 2, 6, 9, 2, 5, 6, 9, 7, 8, 7, 6, 5, 9, 9, 2, 4, 9, 0, 1, 1, 1, 6, 4, 5, 8, 9, 1, 2, 1, 4, 5, 9, 7, 4, 9, 2, 9, 2, 5, 2, 2, 0, 2, 1, 9, 3, 6 ] scatter.yValues = [ 2, 5, 9, 5, 9, 3, 6, 1, 6, 0, 0, 6, 2, 5, 3, 9, 2, 7, 6, 2, 3, 1, 9, 9, 5, 2, 9, 0, 2, 3, 0, 2, 5, 5, 8, 4, 1, 9, 8, 6, 1, 6, 9, 2, 4, 9, 2, 8, 1, 1, 2, 1, 0, 6, 3, 4, 2, 5, 6, 8, 6, 9, 0, 6, 8, 6, 8, 1, 6, 2, 2, 3, 6, 2, 2, 2, 0, 2, 4, 6, 8, 5, 1, 4, 2, 3, 5, 3, 1, 0, 6, 0, 1, 6, 8, 9, 3, 9, 3, 7 ] vline1 = VLine() vline1.xValues = [2, 8] vline1.color = 'CornflowerBlue' vline2 = VLine() vline2.xValues = [1, 9] vline2.color = 'GoldenRod' plot = Plot() plot.hasLegend() plot.add(scatter) plot.add(vline1) plot.add(vline2) plot.save(self.imageName)
def constructImage(self): plot = Plot() # Uneven error bars line = Line() line.xValues = [6,10,4,0,8,2,12] line.yValues = [50,90,30,10,70,20,110] line.yMins = [y - 30 for y in line.yValues] line.yMaxes = [y + 50 for y in line.yValues] line.label = "Asymmetric Errors" line.color = "red" # Even error bars line2 = Line() line2.xValues = [1,5,3,9,7,11] line2.yValues = [100, 120, 110, 140, 130, 150] line2.color = "blue" line2.label = "Symmetric Errors" line2.yErrors = [5,25,15,45,35,55] plot.add(line) plot.add(line2) plot.xLabel = "X Label" plot.yLabel = "Y Label" plot.hasLegend() plot.xLimits = (-1, 13) plot.save(self.imageName)
def main(): output_graph = sys.argv[1] plot = Plot() plot.hasLegend(location='lower right') plot.xLabel = 'Per-client throughput (Mbps)' # Change this plot.yLabel = 'CDF' plot.xLimits = (0, 50) plot.yLimits = (0, 1) plot.legendLabelSize = FONT_SIZE plot.xTickLabelSize = FONT_SIZE - 2 plot.yTickLabelSize = FONT_SIZE - 2 plot.axesLabelSize = FONT_SIZE for csv_file in sys.argv[2:]: cdf_table = _make_cdf(csv_file) line = Line() line.xValues = [x for (x, _) in cdf_table] line.yValues = [y for (_, y) in cdf_table] line.color = colors.pop(0) line.lineStyle = line_styles.pop(0) # Extract the filename line.label = capitalize( csv_file.split('/')[-2].replace('.csv', '') ) plot.add(line) plot.save(output_graph)
def constructImage(self): bar1 = Bar() bar1.xValues = range(5) bar1.yValues = [1, 2, 1, 2, 3] bar1.color = "red" bar1.label = "Red Cluster" bar2 = Bar() bar2.xValues = range(5) bar2.yValues = [2, 2, 3, 3, 4] bar2.color = "blue" bar2.label = "Blue Cluster" bar3 = Bar() bar3.xValues = range(5) bar3.yValues = [3, 5, 4, 5, 3] bar3.color = "green" bar3.label = "Green Cluster" stackedBars = StackedBars() stackedBars.add(bar1) stackedBars.add(bar2) stackedBars.add(bar3) stackedBars.xTickLabels = ["A", "B", "C", "D", "E"] plot = Plot() plot.add(stackedBars) plot.setYLimits(0, 15) plot.hasLegend() plot.save(self.imageName)
def constructImage(self): plot = Plot() # Uneven error bars line = Line() line.xValues = [6, 10, 4, 0, 8, 2, 12] line.yValues = [50, 90, 30, 10, 70, 20, 110] line.yMins = [y - 30 for y in line.yValues] line.yMaxes = [y + 50 for y in line.yValues] line.label = "Asymmetric Errors" line.color = "red" # Even error bars line2 = Line() line2.xValues = [1, 5, 3, 9, 7, 11] line2.yValues = [100, 120, 110, 140, 130, 150] line2.color = "blue" line2.label = "Symmetric Errors" line2.yErrors = [5, 25, 15, 45, 35, 55] plot.add(line) plot.add(line2) plot.xLabel = "X Label" plot.yLabel = "Y Label" plot.hasLegend() plot.xLimits = (-1, 13) plot.save(self.imageName)
def constructImage(self): bar1 = Bar() bar1.xValues = range(5) bar1.yValues = [1, 2, 1, 2, 3] bar1.color = "red" bar1.label = "Red Cluster" bar2 = Bar() bar2.xValues = range(5) bar2.yValues = [2, 2, 3, 3, 4] bar2.color = "blue" bar2.label = "Blue Cluster" bar3 = Bar() bar3.xValues = range(5) bar3.yValues = [3, 5, 4, 5, 3] bar3.color = "green" bar3.label = "Green Cluster" stackedBars = StackedBars() stackedBars.add(bar1) stackedBars.add(bar2) stackedBars.add(bar3) stackedBars.xTickLabels = ["A", "B", "C", "D", "E"] plot = Plot() plot.add(stackedBars) plot.yLimits = (0, 15) plot.hasLegend() plot.save(self.imageName)
def constructImage(self): bar1 = Bar() bar1.xValues = range(5) bar1.yValues = [2, 4, 6, 8, 10] bar1.color = "red" bar1.label = "Red Cluster" bar2 = Bar() bar2.xValues = range(5) bar2.yValues = [3, 12, 4, 8, 14] bar2.color = "blue" bar2.label = "Blue Cluster" bar3 = Bar() bar3.xValues = range(5) bar3.yValues = [1, 6, 9, 13, 20] bar3.color = "green" bar3.label = "Green Cluster" clusteredBars = ClusteredBars() clusteredBars.add(bar1) clusteredBars.add(bar2) clusteredBars.add(bar3) clusteredBars.spacing = 0.5 clusteredBars.xTickLabels = ["A", "B", "C", "D", "E"] plot = Plot() plot.add(clusteredBars) plot.hasLegend() plot.save(self.imageName)
def constructImage(self): cluster = ClusteredBars() colors = ['red','green','blue','CornflowerBlue','LightSalmon'] yVals = [[ [1, 3, 2, 5, 4], [2, 2, 2, 2, 2], [1, 3, 2, 4, 3], [0, 4, 0, 4, 0], [5, 5, 5, 5, 5] ],[ [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2] ], [ [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], ]] for i in xrange(3): stack = StackedBars() for j in xrange(5): bar = Bar() bar.xValues = range(5) bar.yValues = yVals[i][j] bar.color = colors[j] bar.label = "Subject %d" % (j+1,) stack.add(bar) cluster.add(stack) cluster.spacing = 0.5 cluster.xTickLabels = ["1", "2", "3", "4", "5"] plot = Plot() plot.add(cluster) plot.hasLegend() plot.setXLabel('Nested Cars') plot.setYLabel('Party (lampshades)') plot.save(self.imageName)
def latency(output_graph_filename, csv_file_dir_list): """ Plots three graphs side-by-side. First, redis performance; second, pkt-in latency; third, pkt-out latency. """ layout = PlotLayout() redis_plot = Plot() pkt_in_plot = Plot() flow_mod_plot = Plot() redis_plot.yLabel = 'CDF' flow_mod_plot.hasLegend(location='lower right') flow_mod_plot.legendLabelSize = 12 redis_plot.xLabel = '(a) Query completion time (ms)' pkt_in_plot.xLabel = '(b) Switch processing time for ingress (ms)' flow_mod_plot.xLabel = '(c) Switch processing time for egress (ms)' for csv_dir in csv_file_dir_list: color = colors.pop(0) line_style = line_styles.pop(0) line_label = csv_dir.split('/')[-2] attr_dict = {'color': color, 'label': capitalize(line_label), 'yLimits': (0, 1), 'lineStyle': line_style} redis_line = get_line_from_csv(os.path.join(csv_dir, 'async_redis_latency.csv'), xLimits=(0,400), **attr_dict) pkt_in_line = get_line_from_csv(os.path.join(csv_dir, 'pkt_in_durations.csv'), xLimits=(0,140), **attr_dict) flow_mod_line = get_line_from_csv(os.path.join(csv_dir, 'flow_mod_durations.csv'), xLimits=(0,140), **attr_dict) redis_plot.add(redis_line) pkt_in_plot.add(pkt_in_line) flow_mod_plot.add(flow_mod_line) layout.addPlot(redis_plot) layout.addPlot(pkt_in_plot) layout.addPlot(flow_mod_plot) layout.width = 3 layout.setPlotDimensions(4.5,4.5*0.618) layout.save('data/graphs/' + output_graph_filename + '.pdf') print 'Done.'
def constructImage(self): plot = Plot() for i in xrange(6): line = Line() line.xValues = xrange(5) line.yValues = [(i + 1) * x for x in line.xValues] line.label = "Line %d" % (i + 1) plot.add(line) plot.addLineColor("red") plot.addLineColor("blue") plot.addLineColor("green") plot.addMarker("") plot.addMarker("x") plot.hasLegend(columns=2) plot.save(self.imageName)
def constructImage(self): plot = Plot() for i in xrange(24): line = Line() line.xValues = xrange(5) line.yValues = [(i+1) * x for x in line.xValues] line.label = "Line %d" % (i + 1) plot.add(line) plot.addLineColor("red") plot.addLineColor("blue") plot.addLineStyle("-") plot.addLineStyle("dashed") plot.addLineStyle("dotted") plot.addMarker('none') plot.addMarker('x') plot.addMarker('o') plot.hasLegend(columns=2) plot.setLegendLabelSize(8) plot.save(self.imageName)
def constructImage(self): plot = Plot() for i in xrange(24): line = Line() line.xValues = xrange(5) line.yValues = [(i + 1) * x for x in line.xValues] line.label = "Line %d" % (i + 1) plot.add(line) plot.addLineColor("red") plot.addLineColor("blue") plot.addLineStyle("-") plot.addLineStyle("dashed") plot.addLineStyle("dotted") plot.addMarker('none') plot.addMarker('x') plot.addMarker('o') plot.hasLegend(columns=2) plot.setLegendLabelSize(8) plot.save(self.imageName)
def constructImage(self): line = Line() line.xValues = range(5) line.yValues = [2,3,5,7,9] line.label = "A Line" linePlot1 = Plot() linePlot1.title = "Small Legend" linePlot1.add(line) linePlot1.hasLegend() linePlot1.legendLabelSize = 10 linePlot2 = Plot() linePlot2.title = "Large Legend" linePlot2.add(line) linePlot2.hasLegend() linePlot2.legendLabelSize = 30 linePlot3 = Plot() linePlot3.title = "Inherited from Layout" linePlot3.add(line) linePlot3.hasLegend() layout = PlotLayout() layout.width = 2 layout.addPlot(linePlot1) layout.addPlot(linePlot2) layout.addPlot(linePlot3) layout.legendLabelSize = 15 layout.save(self.imageName)
def constructImage(self): line = Line() line.xValues = range(5) line.yValues = [2, 3, 5, 7, 9] line.label = "A Line" linePlot1 = Plot() linePlot1.title = "Small Legend" linePlot1.add(line) linePlot1.hasLegend() linePlot1.legendLabelSize = 10 linePlot2 = Plot() linePlot2.title = "Large Legend" linePlot2.add(line) linePlot2.hasLegend() linePlot2.legendLabelSize = 30 linePlot3 = Plot() linePlot3.title = "Inherited from Layout" linePlot3.add(line) linePlot3.hasLegend() layout = PlotLayout() layout.width = 2 layout.addPlot(linePlot1) layout.addPlot(linePlot2) layout.addPlot(linePlot3) layout.legendLabelSize = 15 layout.save(self.imageName)
def constructImage(self): line = Line() line.xValues = range(5) line.yValues = [2,3,5,7,9] line.label = "A Line" linePlot1 = Plot() linePlot1.setTitle("Small Legend") linePlot1.add(line) linePlot1.hasLegend() linePlot1.setLegendLabelSize(10) linePlot2 = Plot() linePlot2.setTitle("Large Legend") linePlot2.add(line) linePlot2.hasLegend() linePlot2.setLegendLabelSize(30) linePlot3 = Plot() linePlot3.setTitle("Inherited from Layout") linePlot3.add(line) linePlot3.hasLegend() layout = PlotLayout() layout.setWidth(2) layout.addPlot(linePlot1) layout.addPlot(linePlot2) layout.addPlot(linePlot3) layout.setLegendLabelSize(15) layout.setPlotParameters(left=0.03, bottom=0.03, right=0.98, top=0.94) layout.save(self.imageName)
def constructImage(self): cluster = ClusteredBars() colors = ['red', 'green', 'blue', 'CornflowerBlue', 'LightSalmon'] yVals = [[[1, 3, 2, 5, 4], [2, 2, 2, 2, 2], [1, 3, 2, 4, 3], [0, 4, 0, 4, 0], [5, 5, 5, 5, 5]], [[2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2], [2, 2, 2, 2, 2]], [ [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], [1, 3, 1, 3, 1], ]] for i in xrange(3): stack = StackedBars() for j in xrange(5): bar = Bar() bar.xValues = range(5) bar.yValues = yVals[i][j] bar.color = colors[j] bar.label = "Subject %d" % (j + 1, ) stack.add(bar) cluster.add(stack) cluster.spacing = 0.5 cluster.xTickLabels = ["1", "2", "3", "4", "5"] plot = Plot() plot.add(cluster) plot.hasLegend() plot.setXLabel('Nested Cars') plot.setYLabel('Party (lampshades)') plot.save(self.imageName)
def constructImage(self): line1 = Line() line1.xValues = range(7) line1.yValues = [1, 2, 4, 8, 16, 32, 64] line1.label = "First Plot" line1.lineStyle = "-" line1.color = "red" line2 = Line() line2.xValues = range(7) line2.yValues = [100, 90, 80, 70, 60, 50, 40] line2.label = "Second Plot" line2.lineStyle = "--" line2.color = "blue" plot = Plot() plot.add(line1) plot.add(line2) plot.xLabel = "Shared X Axis" plot.yLabel = "First Plot's Y Axis" plot.setTwinX("Second Plot's Y Axis", 1) plot.hasLegend() plot.save(self.imageName)
def constructImage(self): scatter = Scatter() scatter.label="Hooray dots!" scatter.xValues = [ 7, 6, 3, 5, 7, 6, 1, 1, 6, 5, 8, 6, 7, 8, 0, 2, 9, 3, 9, 5, 4, 5, 0, 0, 2, 3, 1, 4, 1, 3, 3, 8, 1, 5, 2, 6, 0, 3, 5, 1, 4, 9, 5, 1, 9, 9, 9, 7, 6, 5, 8, 6, 0, 2, 6, 9, 2, 5, 6, 9, 7, 8, 7, 6, 5, 9, 9, 2, 4, 9, 0, 1, 1, 1, 6, 4, 5, 8, 9, 1, 2, 1, 4, 5, 9, 7, 4, 9, 2, 9, 2, 5, 2, 2, 0, 2, 1, 9, 3, 6] scatter.yValues = [ 2, 5, 9, 5, 9, 3, 6, 1, 6, 0, 0, 6, 2, 5, 3, 9, 2, 7, 6, 2, 3, 1, 9, 9, 5, 2, 9, 0, 2, 3, 0, 2, 5, 5, 8, 4, 1, 9, 8, 6, 1, 6, 9, 2, 4, 9, 2, 8, 1, 1, 2, 1, 0, 6, 3, 4, 2, 5, 6, 8, 6, 9, 0, 6, 8, 6, 8, 1, 6, 2, 2, 3, 6, 2, 2, 2, 0, 2, 4, 6, 8, 5, 1, 4, 2, 3, 5, 3, 1, 0, 6, 0, 1, 6, 8, 9, 3, 9, 3, 7] plot = Plot() plot.hasLegend() plot.add(scatter) plot.save(self.imageName)
#!/usr/bin/env python import random from boomslang import Scatter, Plot scatter = Scatter() scatter.label="Hooray dots!" for i in range(100): scatter.xValues.append(random.uniform(0, 10)) scatter.yValues.append(random.uniform(0, 10)) plot = Plot() plot.hasLegend() plot.add(scatter) plot.save("scatter.png")
def plotExperiments(script_arguments_file): script_arguments_fp = open(script_arguments_file, "r") script_arguments = json.load(script_arguments_fp) script_arguments_fp.close() disk = script_arguments["disk"] sort_strategies = script_arguments["sort_strategies"] max_key_lengths = map(int, script_arguments["max_key_lengths"]) max_value_lengths = map(int, script_arguments["max_value_lengths"]) pareto_as = map(float, script_arguments["pareto_as"]) pareto_bs = map(int, script_arguments["pareto_bs"]) byte_counts = map(int, script_arguments["byte_counts"]) timeout = script_arguments["timeout"] experiments = [(sort_strategy, max_key_length, max_value_length, pareto_a, pareto_b, byte_count) for sort_strategy in sort_strategies for max_key_length in max_key_lengths for max_value_length in max_value_lengths for pareto_a in pareto_as for pareto_b in pareto_bs for byte_count in byte_counts] # Open each file and store information about the experiment file_id = 0 experiment_outcomes = {} for experiment in experiments: filename = os.path.join(disk, "stats_%d.json" % file_id) sort_time = None scratch_size = None if os.path.exists(filename): fp = open(filename, "r") try: stats_json = json.load(fp) # time might not be present if the run timed out if "time" in stats_json: # sort time in seconds sort_time = stats_json["time"] / 1000000.0 # scratch size in megabytes scratch_size = stats_json["scratch_size"] / 1000000.0 except ValueError: # If the JSON somehow doesn't parse, just skip this file pass experiment_outcomes[experiment] = (sort_time, scratch_size) file_id += 1 # Specify colors manually so we can sync up a line to its scatter colors = ["red", "green", "blue", "teal", "orange"] if len(sort_strategies) > len(colors): print >> sys.stderr, "Only %d colors but %d lines" % ( len(colors), len(sort_strategies)) sys.exit(1) # Plot sort time vs scratch size plot = Plot() plot.setXLabel("Scratch Size (MB)") plot.setYLabel("Sort Time (s)") plot.hasLegend(labelSize=8, columns=3) plot.setTitle("Sort Time vs Scratch Size") lines = {} for (sort_strategy, color) in zip(sort_strategies, colors): line = LineAndScatter(sort_strategy, color) lines[sort_strategy] = line for experiment, (sort_time, scratch_size) in \ experiment_outcomes.iteritems(): # Mark this experiment on the line corresponding to its sort strategy line = lines[experiment[0]] if scratch_size is not None: line.add_point(scratch_size, sort_time) map(lambda l: l.add_to_plot(plot), lines.values()) layout = PlotLayout() layout.addPlot(plot) output_file = os.path.join(disk, "SortTimeVsScratchSize.pdf") layout.save(output_file) # Plot Sort time vs Scratch Size of a particular strategy: # First sort the experiments by sort strategy strategy_outcomes = {} for experiment in experiments: sort_strategy = experiment[0] parameters = experiment[1:] if parameters not in strategy_outcomes: strategy_outcomes[parameters] = {} strategy_outcomes[parameters][sort_strategy] = \ experiment_outcomes[experiment] # Create one plot per strategy, with that strategy's scratch size # on the x-axis layout = PlotLayout() for major_sort_strategy in sort_strategies: # Set up plot boilerplate plot = Plot() plot.setXLabel("Scratch Size of %s (MB)" % (major_sort_strategy)) plot.setYLabel("Sort Time (s)") plot.hasLegend(labelSize=8, columns=3) plot.setTitle("Sort Time vs Scratch Size of %s" % (major_sort_strategy)) lines = {} for (sort_strategy, color) in zip(sort_strategies, colors): line = LineAndScatter(sort_strategy, color) lines[sort_strategy] = line # For each configuration, plot the sort times on the y axis, and the # scratch time for the major_sort_strategy on the x-axis for outcome_by_strategy in strategy_outcomes.values(): scratch_size = outcome_by_strategy[major_sort_strategy][1] if scratch_size is not None: # Plot the sort time of each strategy using this scratch # As the x-axis value. for sort_strategy in sort_strategies: sort_time = outcome_by_strategy[sort_strategy][0] lines[sort_strategy].add_point(scratch_size, sort_time) map(lambda l: l.add_to_plot(plot), lines.values()) layout.addPlot(plot) output_file = os.path.join(disk, "SortTimeVsScratchSizeByStrategy.pdf") layout.save(output_file) # Plot individual parameter graphs using median parameters median_max_key_length = median(max_key_lengths) median_max_value_length = median(max_value_lengths) median_pareto_a = median(pareto_as) median_pareto_b = median(pareto_bs) median_byte_count = median(byte_counts) for (parameter_name, x_label, parameter_values, fixed_parameters) in [ ("MaxKeyLength", "Max Key Length (bytes)", max_key_lengths, (None, median_max_value_length, median_pareto_a, median_pareto_b, median_byte_count)), ("MaxValueLength", "Max Value Length (bytes)", max_value_lengths, (median_max_key_length, None, median_pareto_a, median_pareto_b, median_byte_count)), ("ParetoA", "Pareto A", pareto_as, (median_max_key_length, median_max_value_length, None, median_pareto_b, median_byte_count)), ("ParetoB", "Pareto B (bytes)", pareto_bs, (median_max_key_length, median_max_value_length, median_pareto_a, None, median_byte_count)), ("FileSize", "File Size (bytes)", byte_counts, (median_max_key_length, median_max_value_length, median_pareto_a, median_pareto_b, None)) ]: time_plot = Plot() size_plot = Plot() for (plot, label, unit) in [(time_plot, "Sort Time", "s"), (size_plot, "Scratch Size", "MB")]: plot.setXLabel(x_label) plot.setYLabel("%s (%s)" % (label, unit)) plot.hasLegend(labelSize=8, columns=3) plot.setTitle("%s vs %s" % (label, parameter_name)) for (sort_strategy, color) in zip(sort_strategies, colors): # Each sort strategy has its own line on each of the two plots time_line = LineAndScatter(sort_strategy, color) size_line = LineAndScatter(sort_strategy, color) # Compute the set of parameters corresponding to this experiment. for parameter in parameter_values: # Apply this parameter to the None value in the tuple of # fixed parameters. parameters = [sort_strategy] for fixed_parameter in fixed_parameters: if fixed_parameter is None: parameters.append(parameter) else: parameters.append(fixed_parameter) # Plot sort time and scratch size for this experiment (sort_time, scratch_size) = experiment_outcomes[tuple(parameters)] time_line.add_point(parameter, sort_time) size_line.add_point(parameter, scratch_size) # Add lines to plots time_line.add_to_plot(time_plot) size_line.add_to_plot(size_plot) # Save the plot as a pdf layout = PlotLayout() layout.addPlot(time_plot) layout.addPlot(size_plot) output_file = os.path.join(disk, "%s.pdf" % (parameter_name)) layout.save(output_file)
def constructImage(self): bnw = BoxAndWhisker() bnw.label="Whiskers" sequences = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [3, 8, 9, 5, 6, 8, 5, 9, 4, 2, 2, 5, 9, 8, 6, 2, 5, 2, 6, 9, 5, 5, 6, 4, 9, 5, 3, 6, 6, 8, 9, 2, 9, 1, 4, 9, 2, 5, 7, 7, 8, 2, 3, 7, 2, 1, 8, 3, 9, 9, 6, 7, 5, 2, 1, 9, 9, 5, 4, 5, 3, 9, 4, 3, 5, 2, 6, 8, 7, 1, 1, 9, 4, 9, 2, 8, 5, 9, 9, 9, 4, 9, 4, 8, 1, 2, 8, 6, 6, 9, 7, 9, 3, 5, 4, 7, 7, 9, 5, 4], [14, 9, 5, 1, 7, 14, 6, 5, 3, 4, 19, 5, 4, 13, 14, 10, 1, 7, 15, 5, 2, 1, 14, 10, 15, 2, 1, 2, 17, 15, 15, 5, 15, 7, 3, 8, 11, 17, 4, 11, 14, 12, 4, 1, 19, 3, 2, 2, 11, 11, 4, 11, 10, 16, 3, 11, 5, 12, 6, 17, 13, 4, 12, 1, 2, 9, 11, 19, 4, 16, 10, 6, 8, 18, 9, 12, 14, 14, 16, 16, 13, 13, 12, 19, 2, 4, 12, 8, 10, 4, 13, 16, 4, 9, 12, 17, 11, 18, 5, 14], [23, 7, 14, 5, 10, 15, 14, 17, 27, 16, 3, 7, 10, 21, 8, 17, 20, 24, 19, 9, 20, 14, 1, 8, 10, 26, 28, 3, 13, 2, 7, 1, 18, 24, 25, 27, 2, 14, 27, 10, 22, 28, 12, 1, 14, 4, 13, 10, 14, 26, 21, 13, 4, 5, 1, 16, 15, 9, 19, 24, 29, 4, 27, 19, 17, 1, 21, 23, 28, 28, 3, 28, 21, 22, 1, 14, 28, 28, 2, 16, 24, 21, 2, 27, 5, 9, 14, 20, 7, 20, 16, 13, 11, 17, 27, 22, 19, 28, 6, 25], [3, 36, 4, 3, 14, 13, 14, 36, 19, 24, 38, 32, 26, 14, 25, 25, 16, 14, 19, 10, 5, 15, 37, 10, 4, 20, 6, 29, 22, 20, 14, 10, 17, 37, 26, 4, 13, 32, 18, 27, 7, 35, 20, 2, 2, 11, 18, 17, 18, 8, 36, 22, 39, 12, 6, 2, 21, 1, 33, 3, 30, 25, 1, 6, 17, 38, 22, 20, 20, 21, 34, 19, 14, 13, 10, 30, 39, 8, 30, 25, 37, 6, 33, 10, 32, 17, 6, 32, 5, 34, 27, 21, 29, 15, 3, 30, 15, 28, 15, 37], [43, 4, 5, 29, 17, 10, 7, 31, 12, 9, 33, 42, 6, 43, 25, 32, 9, 4, 42, 25, 37, 45, 23, 6, 46, 1, 49, 8, 39, 34, 31, 14, 42, 49, 37, 40, 6, 37, 27, 36, 4, 45, 30, 14, 19, 38, 28, 43, 14, 24, 36, 43, 18, 36, 36, 12, 31, 44, 43, 21, 42, 3, 2, 13, 37, 47, 9, 12, 35, 46, 45, 14, 24, 20, 42, 3, 9, 8, 46, 32, 11, 24, 36, 47, 11, 39, 31, 6, 34, 48, 45, 38, 27, 42, 5, 30, 19, 20, 18, 9], [22, 57, 14, 54, 52, 54, 2, 47, 5, 9, 47, 55, 27, 41, 6, 23, 58, 23, 28, 17, 16, 12, 6, 47, 12, 36, 28, 15, 49, 42, 6, 23, 6, 34, 31, 36, 11, 38, 31, 42, 30, 18, 30, 40, 12, 16, 52, 23, 47, 10, 19, 15, 28, 20, 18, 35, 21, 29, 25, 41, 15, 34, 2, 11, 58, 15, 22, 17, 16, 49, 43, 30, 1, 30, 33, 46, 25, 21, 20, 42, 42, 44, 21, 3, 41, 44, 52, 52, 8, 50, 41, 3, 12, 19, 53, 47, 26, 2, 49, 14], [53, 9, 51, 39, 36, 61, 61, 20, 35, 4, 43, 18, 46, 61, 8, 51, 26, 5, 8, 2, 49, 33, 35, 22, 5, 59, 65, 16, 44, 60, 43, 4, 54, 48, 1, 48, 43, 28, 60, 49, 39, 39, 37, 57, 32, 68, 8, 51, 38, 25, 1, 28, 16, 60, 2, 42, 58, 8, 49, 59, 59, 64, 63, 44, 26, 20, 18, 52, 64, 58, 35, 53, 30, 69, 6, 58, 5, 15, 20, 43, 61, 19, 57, 45, 51, 23, 67, 55, 21, 33, 30, 1, 41, 35, 61, 24, 42, 24, 18, 57], [12, 29, 23, 7, 24, 26, 65, 38, 73, 11, 72, 23, 68, 28, 2, 52, 33, 50, 51, 29, 24, 18, 24, 23, 63, 65, 71, 30, 27, 19, 11, 24, 55, 64, 51, 64, 21, 15, 2, 39, 16, 59, 31, 44, 25, 46, 33, 20, 53, 24, 45, 64, 10, 67, 69, 29, 12, 59, 27, 41, 77, 61, 8, 24, 15, 66, 71, 75, 65, 56, 58, 63, 33, 63, 17, 1, 41, 17, 7, 38, 65, 44, 76, 21, 38, 46, 38, 15, 52, 69, 69, 50, 32, 46, 11, 59, 26, 14, 68, 57], [17, 37, 8, 75, 88, 15, 4, 57, 12, 68, 37, 54, 75, 39, 39, 36, 66, 75, 46, 80, 14, 54, 83, 2, 28, 13, 66, 51, 84, 63, 66, 83, 66, 76, 48, 61, 46, 53, 36, 12, 16, 68, 3, 21, 38, 18, 75, 34, 2, 17, 25, 33, 16, 16, 59, 47, 16, 75, 60, 73, 44, 61, 9, 43, 18, 38, 67, 67, 89, 43, 78, 89, 37, 22, 33, 77, 79, 71, 45, 71, 49, 80, 83, 53, 62, 29, 88, 84, 71, 14, 69, 21, 75, 56, 55, 79, 31, 75, 30, 42] ] xSequence = [] for i in range(10): xSequence.append(sequences[i]) bnw.xSequence = xSequence plot = Plot() plot.hasLegend() plot.add(bnw) plot.save(self.imageName)
def histogram_plot(experiment_log_dir, plot_spec_string, output_filename, has_legend, x_limit, verbose): queries = [ plot_utils.plot_spec_string_to_query(plot_spec_string, 0, "HIST") ] plot_data = metaprogram_utils.process_queries(queries, experiment_log_dir, verbose) if "plot_points" not in plot_data: warnings.warn("No data to plot!") return histogram_data = plot_data["plot_points"][0] cumulative_histogram = {} layout = PlotLayout() layout.dpi = 250 for stat_name in histogram_data: plot = Plot() plot.setTitle(stat_name) if has_legend: plot.hasLegend(labelSize=8) if x_limit is not None: plot.setXLimits(0, x_limit) style_plot(plot, stat_name) for key, points in sorted(histogram_data[stat_name].items()): for size, count in itertools.izip(points["bin"], points["count"]): if size not in cumulative_histogram: cumulative_histogram[size] = 0 cumulative_histogram[size] += count line = Line() line.stepFunction("pre") line.label = str(key) line.xValues = points["bin"] line.yValues = points["count"] plot.add(line) layout.addPlot(plot) cumulative_plot = Plot() if x_limit is not None: cumulative_plot.setXLimits(0, x_limit) cumulative_plot.setTitle("Cumulative Histogram for " + stat_name) style_plot(cumulative_plot, stat_name) line = Line() line.stepFunction("pre") line.xValues = sorted(cumulative_histogram.keys()) line.yValues = [cumulative_histogram[key] for key in line.xValues] cumulative_plot.add(line) layout.addPlot(cumulative_plot) layout.save(output_filename)
scatter3 = Scatter() scatter3.xValues = x scatter3.yValues = surf scatter3.label = "Original Surface" scatter3.markerSize = 1 scatter3.color = "blue" scatterPlot = Plot() scatterPlot.add(scatter1) scatterPlot.add(scatter2) scatterPlot.xLabel = "Distance Along Cross Section" scatterPlot.yLabel = "Surface Height" scatterPlot.setTwinX("1st Derivative", 1) scatterPlot.title = "Surface (filtered)" scatterPlot.hasLegend() layout = PlotLayout() layout.addPlot(scatterPlot) layout.plot() layout.save("profile1_filtered.png") # plot the filtered surface with the original surface scatter1 = Scatter() scatter1.xValues = x scatter1.yValues = surfFiltered scatter1.markerSize = 1 scatter1.label = "Filtered Surface" scatter1.color = "black" scatter2 = Scatter()
#!/usr/bin/env python from boomslang import Line, Plot plot = Plot() for i in xrange(6): line = Line() line.xValues = xrange(5) line.yValues = [(i+1) * x for x in line.xValues] line.label = "Line %d" % (i + 1) plot.add(line) plot.addLineColor("red") plot.addLineColor("blue") plot.addLineStyle("-") plot.addLineStyle("--") plot.addLineStyle(":") plot.hasLegend(columns=2) plot.save("linestyles.png")
def constructImage(self): bnw = BoxAndWhisker() bnw.label = "Whiskers" sequences = [[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ], [ 3, 8, 9, 5, 6, 8, 5, 9, 4, 2, 2, 5, 9, 8, 6, 2, 5, 2, 6, 9, 5, 5, 6, 4, 9, 5, 3, 6, 6, 8, 9, 2, 9, 1, 4, 9, 2, 5, 7, 7, 8, 2, 3, 7, 2, 1, 8, 3, 9, 9, 6, 7, 5, 2, 1, 9, 9, 5, 4, 5, 3, 9, 4, 3, 5, 2, 6, 8, 7, 1, 1, 9, 4, 9, 2, 8, 5, 9, 9, 9, 4, 9, 4, 8, 1, 2, 8, 6, 6, 9, 7, 9, 3, 5, 4, 7, 7, 9, 5, 4 ], [ 14, 9, 5, 1, 7, 14, 6, 5, 3, 4, 19, 5, 4, 13, 14, 10, 1, 7, 15, 5, 2, 1, 14, 10, 15, 2, 1, 2, 17, 15, 15, 5, 15, 7, 3, 8, 11, 17, 4, 11, 14, 12, 4, 1, 19, 3, 2, 2, 11, 11, 4, 11, 10, 16, 3, 11, 5, 12, 6, 17, 13, 4, 12, 1, 2, 9, 11, 19, 4, 16, 10, 6, 8, 18, 9, 12, 14, 14, 16, 16, 13, 13, 12, 19, 2, 4, 12, 8, 10, 4, 13, 16, 4, 9, 12, 17, 11, 18, 5, 14 ], [ 23, 7, 14, 5, 10, 15, 14, 17, 27, 16, 3, 7, 10, 21, 8, 17, 20, 24, 19, 9, 20, 14, 1, 8, 10, 26, 28, 3, 13, 2, 7, 1, 18, 24, 25, 27, 2, 14, 27, 10, 22, 28, 12, 1, 14, 4, 13, 10, 14, 26, 21, 13, 4, 5, 1, 16, 15, 9, 19, 24, 29, 4, 27, 19, 17, 1, 21, 23, 28, 28, 3, 28, 21, 22, 1, 14, 28, 28, 2, 16, 24, 21, 2, 27, 5, 9, 14, 20, 7, 20, 16, 13, 11, 17, 27, 22, 19, 28, 6, 25 ], [ 3, 36, 4, 3, 14, 13, 14, 36, 19, 24, 38, 32, 26, 14, 25, 25, 16, 14, 19, 10, 5, 15, 37, 10, 4, 20, 6, 29, 22, 20, 14, 10, 17, 37, 26, 4, 13, 32, 18, 27, 7, 35, 20, 2, 2, 11, 18, 17, 18, 8, 36, 22, 39, 12, 6, 2, 21, 1, 33, 3, 30, 25, 1, 6, 17, 38, 22, 20, 20, 21, 34, 19, 14, 13, 10, 30, 39, 8, 30, 25, 37, 6, 33, 10, 32, 17, 6, 32, 5, 34, 27, 21, 29, 15, 3, 30, 15, 28, 15, 37 ], [ 43, 4, 5, 29, 17, 10, 7, 31, 12, 9, 33, 42, 6, 43, 25, 32, 9, 4, 42, 25, 37, 45, 23, 6, 46, 1, 49, 8, 39, 34, 31, 14, 42, 49, 37, 40, 6, 37, 27, 36, 4, 45, 30, 14, 19, 38, 28, 43, 14, 24, 36, 43, 18, 36, 36, 12, 31, 44, 43, 21, 42, 3, 2, 13, 37, 47, 9, 12, 35, 46, 45, 14, 24, 20, 42, 3, 9, 8, 46, 32, 11, 24, 36, 47, 11, 39, 31, 6, 34, 48, 45, 38, 27, 42, 5, 30, 19, 20, 18, 9 ], [ 22, 57, 14, 54, 52, 54, 2, 47, 5, 9, 47, 55, 27, 41, 6, 23, 58, 23, 28, 17, 16, 12, 6, 47, 12, 36, 28, 15, 49, 42, 6, 23, 6, 34, 31, 36, 11, 38, 31, 42, 30, 18, 30, 40, 12, 16, 52, 23, 47, 10, 19, 15, 28, 20, 18, 35, 21, 29, 25, 41, 15, 34, 2, 11, 58, 15, 22, 17, 16, 49, 43, 30, 1, 30, 33, 46, 25, 21, 20, 42, 42, 44, 21, 3, 41, 44, 52, 52, 8, 50, 41, 3, 12, 19, 53, 47, 26, 2, 49, 14 ], [ 53, 9, 51, 39, 36, 61, 61, 20, 35, 4, 43, 18, 46, 61, 8, 51, 26, 5, 8, 2, 49, 33, 35, 22, 5, 59, 65, 16, 44, 60, 43, 4, 54, 48, 1, 48, 43, 28, 60, 49, 39, 39, 37, 57, 32, 68, 8, 51, 38, 25, 1, 28, 16, 60, 2, 42, 58, 8, 49, 59, 59, 64, 63, 44, 26, 20, 18, 52, 64, 58, 35, 53, 30, 69, 6, 58, 5, 15, 20, 43, 61, 19, 57, 45, 51, 23, 67, 55, 21, 33, 30, 1, 41, 35, 61, 24, 42, 24, 18, 57 ], [ 12, 29, 23, 7, 24, 26, 65, 38, 73, 11, 72, 23, 68, 28, 2, 52, 33, 50, 51, 29, 24, 18, 24, 23, 63, 65, 71, 30, 27, 19, 11, 24, 55, 64, 51, 64, 21, 15, 2, 39, 16, 59, 31, 44, 25, 46, 33, 20, 53, 24, 45, 64, 10, 67, 69, 29, 12, 59, 27, 41, 77, 61, 8, 24, 15, 66, 71, 75, 65, 56, 58, 63, 33, 63, 17, 1, 41, 17, 7, 38, 65, 44, 76, 21, 38, 46, 38, 15, 52, 69, 69, 50, 32, 46, 11, 59, 26, 14, 68, 57 ], [ 17, 37, 8, 75, 88, 15, 4, 57, 12, 68, 37, 54, 75, 39, 39, 36, 66, 75, 46, 80, 14, 54, 83, 2, 28, 13, 66, 51, 84, 63, 66, 83, 66, 76, 48, 61, 46, 53, 36, 12, 16, 68, 3, 21, 38, 18, 75, 34, 2, 17, 25, 33, 16, 16, 59, 47, 16, 75, 60, 73, 44, 61, 9, 43, 18, 38, 67, 67, 89, 43, 78, 89, 37, 22, 33, 77, 79, 71, 45, 71, 49, 80, 83, 53, 62, 29, 88, 84, 71, 14, 69, 21, 75, 56, 55, 79, 31, 75, 30, 42 ]] xSequence = [] for i in range(10): xSequence.append(sequences[i]) bnw.xSequence = xSequence plot = Plot() plot.hasLegend() plot.add(bnw) plot.save(self.imageName)