def constructImage(self): def generatePlot(stepType): line = Line() line.xValues = xVals line.yValues = yVals line.marker = 'o' line.stepFunction(stepType) plot = Plot() plot.add(line) plot.setTitle(r'"%s" Steps' % (stepType)) plot.setXLimits(0, 6) plot.setYLimits(0, 6) return plot xVals = [1, 2, 3, 4, 5] yVals = [1, 2, 3, 4, 5] prePlot = generatePlot("pre") midPlot = generatePlot("mid") postPlot = generatePlot("post") layout = PlotLayout() layout.width = 3 layout.addPlot(prePlot) layout.addPlot(midPlot) layout.addPlot(postPlot) layout.setPlotParameters(right=0.96, left=0.04) layout.save(self.imageName)
def constructImage(self): layout = PlotLayout() plotBase10 = Plot() plotBase10.loglog = True lineBase10 = Line() lineBase10.marker = 'x' lineBase10.xValues = [1, 10, 100, 1000, 10000] lineBase10.yValues = [1, 25, 140, 1024, 10342] plotBase10.add(lineBase10) plotBase2 = Plot() plotBase2.logx = True plotBase2.logbase = 2 lineBase2 = Line() lineBase2.marker = 'x' lineBase2.xValues = [1, 2, 4, 8, 16, 32, 64] lineBase2.yValues = [1, 2, 3, 4, 5, 6, 7] plotBase2.add(lineBase2) layout.addPlot(plotBase10) layout.addPlot(plotBase2) layout.width = 2 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): xVals = [1, 2, 3, 4, 5] yVals = [1, 2, 3, 4, 5] def generatePlot(stepType): line = Line() line.xValues = xVals line.yValues = yVals line.marker = 'o' line.stepFunction(stepType) plot = Plot() plot.add(line) plot.title = r'"%s" Steps' % (stepType) plot.xLimits = (0, 6) plot.yLimits = (0, 6) return plot prePlot = generatePlot("pre") midPlot = generatePlot("mid") postPlot = generatePlot("post") layout = PlotLayout() layout.width = 3 layout.addPlot(prePlot) layout.addPlot(midPlot) layout.addPlot(postPlot) 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 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): line = Line() line.xValues = numpy.arange(0, 150, 0.01) line.yValues = numpy.cos(.02 * numpy.pi * line.xValues) plot = Plot() plot.add(line) plot.xLimits = (0, 150) plot.yLimits = (-1, 1) plot.xLabel = "X" plot.yLabel = "cos(X)" splitPlots = plot.split(2) layout = PlotLayout() layout.width = 2 layout.addPlot(plot, grouping="unsplit") for s in splitPlots: layout.addPlot(s, grouping="splits") layout.save(self.imageName)
xVals = [1, 2, 3, 4, 5] yVals = [1, 2, 3, 4, 5] def generatePlot(stepType): line = Line() line.xValues = xVals line.yValues = yVals line.marker = 'o' line.stepFunction(stepType) plot = Plot() plot.add(line) plot.setTitle(r'"%s" Steps' % (stepType)) plot.setXLimits(0, 6) plot.setYLimits(0, 6) return plot prePlot = generatePlot("pre") midPlot = generatePlot("mid") postPlot = generatePlot("post") layout = PlotLayout() layout.width = 3 layout.addPlot(prePlot) layout.addPlot(midPlot) layout.addPlot(postPlot) layout.setPlotParameters(right=0.96, left=0.04) layout.save("steps.png")