def get_line_from_csv(filename, **attr_dict):

    xs = []
    ys = []
    
    with open(filename) as fobj:
        for line in fobj:
            line = line.strip()
            if line:
                if ',' in line:
                    (x, y) = line.split(',')
                elif '\t' in line:
                    (x, y) = line.split('\t')
                else:
                    (x, y) = line.split()
                xs += [float(x)]
                ys += [float(y)]
                
    line = Line()
    line.xValues = xs
    line.yValues = ys
    
    for (attr, value) in attr_dict.items():
        setattr(line, attr, value)
    
    return line             
Exemple #2
0
    def constructImage(self):
        lines = []

        for i in xrange(3):
            line = Line()
            line.xValues = xrange(5)
            line.yValues = [(i+1 / 2.0) *  pow(x, i+1) for x in line.xValues]
            line.label = "Line %d" % (i + 1)
            lines.append(line)

        plot = Plot()
        plot.add(lines[0])

        inset = Plot()
        inset.add(lines[1])
        inset.hideTickLabels()
        inset.title = ("Inset in Yo Inset\nSo You Can Inset\nWhile You Inset")

        insideInset = Plot()
        insideInset.hideTickLabels()
        insideInset.add(lines[2])

        inset.addInset(insideInset, width=0.4, height=0.3,
                       location="upper left")

        plot.addInset(inset, width=0.4, height=0.4, location="lower right")

        plot.save(self.imageName)
Exemple #3
0
    def constructImage(self):
        lines = []

        for i in xrange(3):
            line = Line()
            line.xValues = xrange(5)
            line.yValues = [(i+1 / 2.0) *  pow(x, i+1) for x in line.xValues]
            line.label = "Line %d" % (i + 1)
            lines.append(line)

        plot = Plot()
        plot.add(lines[0])

        inset = Plot()
        inset.add(lines[1])
        inset.hideTickLabels()
        inset.setTitle("Inset in Yo Inset\nSo You Can Inset\nWhile You Inset")

        insideInset = Plot()
        insideInset.hideTickLabels()
        insideInset.add(lines[2])

        inset.addInset(insideInset, width=0.4, height=0.3,
                       location="upper left")

        plot.addInset(inset, width=0.4, height=0.4, location="lower right")

        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):
        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.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):
        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 = [2, 1, 3, 4, 0]
        line.yValues = [2, 1, 3, 4, 0]

        plot = Plot()
        plot.add(line)

        plot.save(self.imageName)
    def constructImage(self):
        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot = Plot()
        plot.add(line)
        plot.xLabel = "X Label"
        plot.yLabel = "Y Label"
        plot.yLimits = (0, 60)
        plot.save(self.imageName)
Exemple #10
0
    def __init__(self, label, color):
        line = Line()
        line.marker = "."
        line.label = label
        line.color = color
        self.line = line

        scatter = Scatter()
        scatter.marker = "x"
        scatter.color = color
        scatter.markerSize = 200
        self.scatter = scatter
Exemple #11
0
    def constructImage(self):
        plot = Plot()
        plot.projection = 'polar'

        r = arange(0,1,0.001)
        theta = 2*2*pi*r

        line = Line()
        line.xValues = theta
        line.yValues = r
        plot.add(line)
        plot.save(self.imageName)
Exemple #12
0
    def constructImage(self):
        line = Line()
        line.xValues = range(5)
        line.yValues = [2, 4, 6, 8, 10]

        linePlot = Plot()
        linePlot.add(line)
        linePlot.setXLabel("X Data")
        linePlot.setYLabel("Y Data")
        linePlot.setTitle("Data as Line")

        bar = Bar()
        bar.xValues = range(5)
        bar.yValues = [2, 4, 6, 8, 10]

        barPlot = Plot()

        barPlot.add(bar)
        barPlot.setXLabel("X Data")
        barPlot.setYLabel("Y Data")
        barPlot.setTitle("Data as Bars")

        scatter = Scatter()
        scatter.xValues = range(5)
        scatter.yValues = [2, 4, 6, 8, 10]

        scatterPlot = Plot()
        scatterPlot.add(scatter)
        scatterPlot.setXLabel("X Data")
        scatterPlot.setYLabel("Y Data")
        scatterPlot.setTitle("Data as Points")


        layout = PlotLayout()
        # Plots in the same grouping are placed together on the same line
        layout.addPlot(linePlot, grouping="topRow")
        layout.addPlot(barPlot, grouping="topRow")

        # Plots without a grouping are arranged as follows:

        # * While you can make a row of N plots, where N is the size of the plot
        # grouping with the largest size, do so.

        # * If you can't make a row of N plots, make the plots stretch across a
        # single row.

        layout.addPlot(scatterPlot)

        # Set values similar to those given in the "Configure subplots" sliders
        # in the interactive figure
        layout.setPlotParameters(hspace=0.48)
        layout.save(self.imageName)
Exemple #13
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot.add(line)
        plot.setXLabel("X Label")
        plot.setYLabel("Y Label")
        plot.setYLimits(0, 60)

        plot.save(self.imageName)
Exemple #14
0
    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)
Exemple #15
0
    def constructImage(self):
        line = Line()
        line.xValues = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        line.yValues = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

        plot = Plot()
        plot.useLatexLabels()
        plot.xLabel = r"$x$"
        plot.yLabel = r"$f(x) = x^2$"
        plot.title = (r"LaTeX is Number $\sum_{n=1}^{\infty}"
                      r"\frac{-e^{i\pi}}{2^n}$")
        plot.add(line)
        plot.tight = True
        plot.axesLabelSize = 18
        plot.save(self.imageName)
    def constructImage(self):
        line = Line()
        line.xValues = range(5)
        line.yValues = [2, 4, 6, 8, 10]

        linePlot = Plot()
        linePlot.add(line)
        linePlot.xLabel = "X Data"
        linePlot.yLabel = "Y Data"
        linePlot.title = "Data as Line"

        bar = Bar()
        bar.xValues = range(5)
        bar.yValues = [2, 4, 6, 8, 10]

        barPlot = Plot()

        barPlot.add(bar)
        barPlot.xLabel = "X Data"
        barPlot.yLabel = "Y Data"
        barPlot.title = "Data as Bars"

        scatter = Scatter()
        scatter.xValues = range(5)
        scatter.yValues = [2, 4, 6, 8, 10]

        scatterPlot = Plot()
        scatterPlot.add(scatter)
        scatterPlot.xLabel = "X Data"
        scatterPlot.yLabel = "Y Data"
        scatterPlot.title = "Data as Points"

        layout = WeightedPlotLayout()
        # Plots in the same grouping are placed together on the same line
        layout.addPlot(linePlot, grouping="topRow", weight=2)
        layout.addPlot(barPlot, grouping="topRow")

        # Plots without a grouping are arranged as follows:

        # * While you can make a row of N plots, where N is the size of the plot
        # grouping with the largest size, do so.

        # * If you can't make a row of N plots, make the plots stretch across a
        # single row.

        layout.addPlot(scatterPlot)

        layout.save(self.imageName)
Exemple #17
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot.add(line)
        plot.xLabel = "X Label"
        plot.yLabel = "Y Label"
        plot.yLimits = (0, 60)

        plot.grid.color = "#ff0000"
        plot.grid.style = "dotted"
        plot.grid.visible = True

        plot.save(self.imageName)
Exemple #18
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot.add(line)
        plot.xLabel = "X Label"
        plot.yLabel = "Y Label"
        plot.yLimits = (0, 60)

        plot.grid.color = "#ff0000"
        plot.grid.style = "dotted"
        plot.grid.visible = True

        plot.save(self.imageName)
Exemple #19
0
    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()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot.add(line)
        plot.xLabel = "X Label"
        plot.yLabel = "Y Label"
        plot.yLimits = (0, 60)

        plot.xTickLabelSize = 24
        plot.yTickLabelSize = 36
        plot.axesLabelSize = 18
        plot.tight = True

        plot.save(self.imageName)
Exemple #21
0
    def constructImage(self):
        line = Line()
        line.xValues = [0, 1, 2, 3, 4, 5,
                        6, 7, 8, 9, 10]
        line.yValues = [0, 1, 4, 9, 16, 25,
                        36, 49, 64, 81, 100]

        plot = Plot()
        plot.useLatexLabels()
        plot.xLabel = r"$x$"
        plot.yLabel = r"$f(x) = x^2$"
        plot.title = (
            r"LaTeX is Number $\sum_{n=1}^{\infty}"
            r"\frac{-e^{i\pi}}{2^n}$")
        plot.add(line)
        plot.tight = True
        plot.axesLabelSize = 18
        plot.save(self.imageName)
Exemple #22
0
    def testExactSize(self):
        plot = Plot()
        line = Line()
        plot.setDimensions(3, 4)

        line.xValues = range(5)
        line.yValues = range(5)

        plot.add(line)
        plot.save(self.imageName)

        im = Image.open(self.imageName)
        self.assertEqual(im.size, (300,400))

        plot.setDimensions(3,4,dpi=250)

        plot.save(self.imageName)
        im = Image.open(self.imageName)
        self.assertEqual(im.size, (750,1000))
    def testExactSize(self):
        plot = Plot()
        line = Line()
        plot.setDimensions(3, 4)

        line.xValues = range(5)
        line.yValues = range(5)

        plot.add(line)
        plot.save(self.imageName)

        im = Image.open(self.imageName)
        self.assertEqual(im.size, (300, 400))

        plot.setDimensions(3, 4, dpi=250)

        plot.save(self.imageName)
        im = Image.open(self.imageName)
        self.assertEqual(im.size, (750, 1000))
Exemple #24
0
    def constructImage(self):
        line = Line()
        line.xValues = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
        line.yValues = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]

        plot = Plot()
        plot.useLatexLabels()
        plot.setXLabel(r"$x$")
        plot.setYLabel(r"$f(x) = x^2$")
        plot.setTitle(r"LaTeX is Number $\sum_{n=1}^{\infty}\frac{-e^{i\pi}}{2^n}$")
        plot.add(line)

        layout = PlotLayout()
        layout.useLatexLabels()
        layout.addPlot(plot)

        layout.setAxesLabelSize(18)
        layout.setPlotParameters(top=0.84)
        layout.save(self.imageName)
Exemple #25
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))

        plot.add(line)
        plot.setXLabel("X Label")
        plot.setYLabel("Y Label")
        plot.setYLimits(0, 60)

        plot.setXTickLabelSize(24)
        plot.setYTickLabelSize(36)
        plot.setAxesLabelSize(18)

        plot.setPlotParameters(bottom=0.14)

        plot.save(self.imageName)
Exemple #26
0
    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)
Exemple #27
0
    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)
Exemple #28
0
    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)
Exemple #29
0
    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)
Exemple #30
0
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)
Exemple #31
0
    def constructImage(self):
        line = Line()
        line.xValues = range(5)
        line.yValues = [2, 4, 6, 8, 10]

        linePlot = Plot()
        linePlot.add(line)
        linePlot.xLabel = "X Data"
        linePlot.yLabel = "Y Data"
        linePlot.title = "Data as Line"

        bar = Bar()
        bar.xValues = range(5)
        bar.yValues = [2, 4, 6, 8, 10]

        barPlot = Plot()

        barPlot.add(bar)
        barPlot.xLabel = "X Data"
        barPlot.yLabel = "Y Data"
        barPlot.title = "Data as Bars"

        scatter = Scatter()
        scatter.xValues = range(5)
        scatter.yValues = [2, 4, 6, 8, 10]

        scatterPlot = Plot()
        scatterPlot.add(scatter)
        scatterPlot.xLabel = "X Data"
        scatterPlot.yLabel = "Y Data"
        scatterPlot.title = "Data as Points"

        layout = PlotLayout()

        layout.addPlot(linePlot, grouping="topRow")
        layout.addPlot(barPlot, grouping="topRow")

        layout.addPlot(scatterPlot)

        layout.save(self.imageName)
Exemple #32
0
    def constructImage(self):
        line = Line()
        line.xValues = numpy.arange(0.0, 5.0, 0.01)
        line.yValues = numpy.cos(2 * numpy.pi * line.xValues)

        maxLabel = Label(2, 1, "Maximum!")
        maxLabel.textOffset = (0.5, 0.5)
        maxLabel.hasArrow()

        minLabel = Label(1.5, -1, "Minimum!")
        minLabel.textPosition = (1, -2)
        minLabel.hasArrow()

        randomLabel = Label(2, -1.7, "A Point!")
        randomLabel.textOffset = (0, 0.2)
        randomLabel.marker = 'o'

        styledLabel = Label(1.25,
                            1.2,
                            "A FancyPoint!",
                            bbox={
                                'edgecolor': 'red',
                                'facecolor': 'white',
                                'ls': 'dashed',
                                'lw': '2'
                            })
        styledLabel.textOffset = (0, 0.2)
        styledLabel.marker = 'o'

        plot = Plot()
        plot.add(line)
        plot.add(minLabel)
        plot.add(maxLabel)
        plot.add(randomLabel)
        plot.add(styledLabel)
        plot.yLimits = (-3, 3)
        plot.xLabel = "X"
        plot.yLabel = "cos(x)"
        plot.save("label.png")
        plot.save(self.imageName)
Exemple #33
0
    def constructImage(self):
        line = Line()
        line.xValues = range(5)
        line.yValues = [2, 4, 6, 8, 10]

        linePlot = Plot()
        linePlot.add(line)
        linePlot.xLabel = "X Data"
        linePlot.yLabel = "Y Data"
        linePlot.title = "Data as Line"

        bar = Bar()
        bar.xValues = range(5)
        bar.yValues = [2, 4, 6, 8, 10]

        barPlot = Plot()

        barPlot.add(bar)
        barPlot.xLabel = "X Data"
        barPlot.yLabel = "Y Data"
        barPlot.title = "Data as Bars"

        scatter = Scatter()
        scatter.xValues = range(5)
        scatter.yValues = [2, 4, 6, 8, 10]

        scatterPlot = Plot()
        scatterPlot.add(scatter)
        scatterPlot.xLabel = "X Data"
        scatterPlot.yLabel = "Y Data"
        scatterPlot.title = "Data as Points"

        layout = PlotLayout()

        layout.addPlot(linePlot, grouping="topRow")
        layout.addPlot(barPlot, grouping="topRow")

        layout.addPlot(scatterPlot)

        layout.save(self.imageName)
Exemple #34
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.xValues = xrange(100)
        line.xTickLabels = [
            "Whoa this label is really long why is this label so long"
        ]
        line.xTickLabelPoints = [42]
        line.xTickLabelProperties["rotation"] = 45
        line.yValues = [math.sin(x) for x in xrange(100)]
        line.yTickLabels = ["Look at this value. Pretty sweet value right?"]
        line.yTickLabelPoints = [0.3]

        plot.add(line)
        plot.setXLabel("Value")
        plot.setYLabel("sin(Value)")

        plot.save(self.imageName)
Exemple #35
0
    def constructImage(self):
        line = Line()
        line.xValues = numpy.arange(0.0, 5.0, 0.01)
        line.yValues = numpy.cos(2 * numpy.pi * line.xValues)

        maxLabel = Label(2, 1, "Maximum!")
        maxLabel.textOffset = (0.5, 0.5)
        maxLabel.hasArrow()

        minLabel = Label(1.5, -1, "Minimum!")
        minLabel.textPosition = (1, -2)
        minLabel.hasArrow()

        randomLabel = Label(2, -1.7, "A Point!")
        randomLabel.textOffset = (0, 0.2)
        randomLabel.marker = 'o'

        styledLabel = Label(1.25, 1.2, "A FancyPoint!",
                            bbox={'edgecolor':'red',
                                  'facecolor':'white',
                                  'ls':'dashed',
                                  'lw':'2'})
        styledLabel.textOffset = (0, 0.2)
        styledLabel.marker = 'o'

        plot = Plot()
        plot.add(line)
        plot.add(minLabel)
        plot.add(maxLabel)
        plot.add(randomLabel)
        plot.add(styledLabel)
        plot.yLimits = (-3, 3)
        plot.xLabel = "X"
        plot.yLabel = "cos(x)"
        plot.save("label.png")
        plot.save(self.imageName)
Exemple #36
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.xValues = xrange(100)
        line.xTickLabels = ["Whoa this label is really long why is this label so long"]
        line.xTickLabelPoints = [42]
        line.xTickLabelProperties["rotation"] = 45
        line.yValues = [math.sin(x) for x in xrange(100)]
        line.yTickLabels = ["Look at this value. Pretty sweet value right?"]
        line.yTickLabelPoints = [0.3]

        plot.add(line)
        plot.setXLabel("Value")
        plot.setYLabel("sin(Value)")

        plot.save(self.imageName)
Exemple #37
0
def make_line_objects_for_stat_name(query_number, stat_name, stat_name_data,
                                    min_timestamps):

    lines = []

    for points_info in sorted(stat_name_data):
        lines_dict = {}
        lines_dict["query_number"] = query_number
        lines_dict["stat_name"] = stat_name

        hostname = points_info[0].split('.')[0][-3:]

        if len(points_info) == 4:
            (phase, stage, worker_id) = points_info[1:]
            lines_dict["stage"] = stage
            lines_dict["worker_id"] = worker_id
            label = "h:%s s:%s i:%d n:%s" % (hostname, stage, worker_id,
                                             stat_name)

        elif len(points_info) == 3:
            (phase, logger_name) = points_info[1:]
            lines_dict["logger_name"] = logger_name
            label = "h:%s l:%s n:%s" % (hostname, logger_name, stat_name)

        lines_dict["hostname"] = hostname
        lines_dict["phase"] = phase

        min_timestamp = min_timestamps[phase]

        def timestamp_adjuster(x):
            """
            Adjust an absolute timestamp in microseconds to time in seconds
            relative to the min timestamp
            """
            return float(x - min_timestamp) / 1000000.0

        time_series_line = Line()
        time_series_line.label = label
        time_series_line.stepFunction("pre")

        time_series_line.xValues = map(timestamp_adjuster,
                                       stat_name_data[points_info]["x_values"])
        time_series_line.yValues = stat_name_data[points_info]["y_values"]

        lines_dict["time_series_line"] = time_series_line
        lines_dict["cdf_line"] = Utils.getCDF(
            stat_name_data[points_info]["y_values"])
        lines_dict["cdf_line"].label = label

        lines.append(lines_dict)
    return lines
Exemple #38
0
        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
    def constructImage(self):
        line1 = Line()
        line2 = Line()
        line3 = Line()

        line1.xValues = range(0,10)
        line1.yValues = [2,5,2,3,2,2,1,0,1,0]
        line2.xValues = range(0,10)
        line2.yValues = [3,1,2,3,2,1,5,3,1,7]
        line3.xValues = range(0,10)
        line3.yValues = [2,1,3,1,3,4,1,4,5,0]

        stack = StackedLines()
        stack.addLine(line1, "red")
        stack.addLine(line2, "green")
        stack.addLine(line3, "blue")

        plot = Plot()
        plot.xLimits = (0, 9)
        plot.yLimits = (0, 7)
        plot.add(stack)
        plot.save(self.imageName)
def make_line_objects_for_stat_name(
    query_number, stat_name, stat_name_data, min_timestamps):

    lines = []

    for points_info in sorted(stat_name_data):
        lines_dict = {}
        lines_dict["query_number"] = query_number
        lines_dict["stat_name"] = stat_name

        hostname = points_info[0].split('.')[0][-3:]

        if len(points_info) == 4:
            (phase, stage, worker_id) = points_info[1:]
            lines_dict["stage"] = stage
            lines_dict["worker_id"] = worker_id
            label = "h:%s s:%s i:%d n:%s" % (
                hostname, stage, worker_id, stat_name)

        elif len(points_info) == 3:
            (phase, logger_name) = points_info[1:]
            lines_dict["logger_name"] = logger_name
            label = "h:%s l:%s n:%s" % (
                hostname, logger_name, stat_name)

        lines_dict["hostname"] = hostname
        lines_dict["phase"] = phase

        min_timestamp = min_timestamps[phase]

        def timestamp_adjuster(x):
            """
            Adjust an absolute timestamp in microseconds to time in seconds
            relative to the min timestamp
            """
            return float(x - min_timestamp) / 1000000.0

        time_series_line = Line()
        time_series_line.label = label
        time_series_line.stepFunction("pre")

        time_series_line.xValues = map(
            timestamp_adjuster, stat_name_data[points_info]["x_values"])
        time_series_line.yValues = stat_name_data[points_info]["y_values"]

        lines_dict["time_series_line"] = time_series_line
        lines_dict["cdf_line"] = Utils.getCDF(
            stat_name_data[points_info]["y_values"])
        lines_dict["cdf_line"].label = label

        lines.append(lines_dict)
    return lines
Exemple #41
0
        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
Exemple #42
0
#!/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")
Exemple #43
0
    def constructImage(self):
        plot = Plot()

        line = Line()
        line.yValues = [25, 40, 30, 23, 10, 50]
        line.xValues = range(len(line.yValues))
        line.xTickLabels = ["X 1", "X 2", "X 3", "X 4", "X 5"]
        line.yTickLabels = ["Y Ten", "Y Twenty", "Y Thirty", "Y Forty",
                            "Y Fifty", "Y Sixty"]
        line.yTickLabelPoints = [10, 20, 30, 40, 50, 60]

        # You can set tick label properties with a dictionary ...

        line.xTickLabelProperties = {
            "color" : "blue",
            "weight" : "bold",
            "rotation" : 45
            }

        line.yTickLabelProperties = {
            "style" : "italic",
            "alpha" : 0.5,
            "color" : "red"
            }

        # (clearing for demonstrative purposes)
        line.xTickLabelProperties.clear()
        line.yTickLabelProperties.clear()

        # You can also set by direct elementwise access

        line.xTickLabelProperties["color"] = "blue"
        line.xTickLabelProperties["weight"] = "bold"
        line.xTickLabelProperties["rotation"] = "45"

        line.yTickLabelProperties["style"] = "italic"
        line.yTickLabelProperties["alpha"] = 0.5
        line.yTickLabelProperties["color"] = "red"

        plot.add(line)
        plot.title = "Craaazy Title"
        plot.setTitleProperties(
            style="italic", weight="bold", rotation="5",
            color="orange")
        plot.xLabel = "X Label"
        plot.yLabel = "Y Label"
        plot.yLimits = (0, 60)
        plot.tight = True

        plot.save(self.imageName)
Exemple #44
0
def time_of_trial(data):
    return (data[u'end_time'] -
            data[u'start_time']) if u'success' in data else 1000000


def times_of_trials(trial_datas):
    return [time_of_trial(data) for data in trial_datas]


root_dir = sys.argv[1] if len(sys.argv) >= 2 else "results"

dirs = os.listdir(root_dir)
sort_nicely(dirs)
num_tests = len(dirs)
avg_test_times = [
    avg_time_for_test(os.path.join(root_dir, a_dir)) for a_dir in dirs
]

plot = Plot()

x_vals = [int(a_dir.split("-")[0]) for a_dir in dirs]

line = Line()
line.yValues = avg_test_times
line.xValues = x_vals
plot.add(line)

plot.xLabel = "# Clients"
plot.yLabel = "Miliseconds"
plot.save("mega_graph.png")
Exemple #45
0
    def constructImage(self):
        line1 = Line()
        line2 = Line()
        line3 = Line()

        line1.xValues = range(0, 10)
        line1.yValues = [2, 5, 2, 3, 2, 2, 1, 0, 1, 0]
        line2.xValues = range(0, 10)
        line2.yValues = [3, 1, 2, 3, 2, 1, 5, 3, 1, 7]
        line3.xValues = range(0, 10)
        line3.yValues = [2, 1, 3, 1, 3, 4, 1, 4, 5, 0]

        stack = StackedLines()
        stack.addLine(line1, "red")
        stack.addLine(line2, "green")
        stack.addLine(line3, "blue")

        plot = Plot()
        plot.xLimits = (0, 9)
        plot.yLimits = (0, 7)
        plot.add(stack)
        plot.save(self.imageName)
Exemple #46
0
    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)
Exemple #47
0
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)
Exemple #48
0
    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)
Exemple #49
0
    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)
Exemple #50
0
        for test in client_data:
            if u'success' in test:
                client_run.append(test[u'end_time'] - test[u'start_time'])
            else:
                client_run.append(0)
        runs.append(client_run)

average_run = []
for i in range(0, len(runs[0])):
    average_run.append(sum([a_run[i] for a_run in runs]) / len(runs))

print average_run
plot = Plot()

for run in runs:
    line = Line()
    line.yValues = run
    line.xValues = list(range(0, len(run)))
    plot.add(line)

# Also add in the average line
avg_line = Line()
avg_line.yValues = average_run
avg_line.xValues = list(range(0, len(run)))
avg_line.color = 'r'
plot.add(avg_line)

plot.xLabel = "Test Index"
plot.yLabel = "Miliseconds"
plot.save(os.path.join(data_dir, "graph.png"))