Example #1
0
#!/usr/bin/env python

from boomslang import Plot, Line
from ImageComparisonTestCase import ImageComparisonTestCase
import unittest


class UnorderedTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(UnorderedTest, self).__init__(testCaseName)
        self.imageName = "unordered.png"

    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)


ImageComparisonTestCase.register(UnorderedTest)

if __name__ == "__main__":
    test = UnorderedTest("testImageComparison")

    test.constructImage()
Example #2
0
        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)

ImageComparisonTestCase.register(ClusteredBarsTest)

if __name__ == "__main__":
    test = ClusteredBarsTest("testImageComparison")

    test.constructImage()
Example #3
0
        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.setTitle("Craaazy Title")
        plot.setTitleProperties(style="italic", weight="bold", rotation="5",
                                color="orange")
        plot.setXLabel("X Label")
        plot.setYLabel("Y Label")
        plot.setYLimits(0, 60)

        plot.setPlotParameters(bottom=.15, left=0.15)

        plot.save(self.imageName)

ImageComparisonTestCase.register(TickStylesTest)

if __name__ == "__main__":
    test = TickStylesTest("testImageComparison")

    test.constructImage()
Example #4
0
        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)

ImageComparisonTestCase.register(TickStylesTest)

if __name__ == "__main__":
    test = TickStylesTest("testImageComparison")

    test.constructImage()
Example #5
0
    def __init__(self, testCaseName):
        super(LineStyles2Test, self).__init__(testCaseName)
        self.imageName = "linestyles2.png"

    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)


ImageComparisonTestCase.register(LineStyles2Test)

if __name__ == "__main__":
    test = LineStyles2Test("testImageComparison")

    test.constructImage()
Example #6
0
class LargeLabelTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(LargeLabelTest, self).__init__(testCaseName)
        self.imageName = "largelabel.png"

    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)

ImageComparisonTestCase.register(LargeLabelTest)

if __name__ == "__main__":
    test = LargeLabelTest("testImageComparison")

    test.constructImage()

Example #7
0
        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)

ImageComparisonTestCase.register(LogScaleTest)

if __name__ == "__main__":
    test = LogScaleTest("testImageComparison")

    test.constructImage()
Example #8
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)


ImageComparisonTestCase.register(StackedLinesTest)

if __name__ == "__main__":
    test = StackedLinesTest("testImageComparison")

    test.constructImage()
Example #9
0
import unittest

class CustomGridTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(CustomGridTest,self).__init__(testCaseName)
        self.imageName = "customgrid.png"

    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)

ImageComparisonTestCase.register(CustomGridTest)

if __name__ == "__main__":
    test = CustomGridTest("testImageComparison")
    test.constructImage()
Example #10
0
            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)

ImageComparisonTestCase.register(InsetTest)

if __name__ == "__main__":
    test = InsetTest("testImageComparison")

    test.constructImage()
Example #11
0
            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)

ImageComparisonTestCase.register(InsetTest)

if __name__ == "__main__":
    test = InsetTest("testImageComparison")

    test.constructImage()
Example #12
0
        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)


ImageComparisonTestCase.register(LogScaleTest)

if __name__ == "__main__":
    test = LogScaleTest("testImageComparison")

    test.constructImage()
Example #13
0
from boomslang import Bar, Plot
import unittest
from ImageComparisonTestCase import ImageComparisonTestCase

class HatchedBarsTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(HatchedBarsTest, self).__init__(testCaseName)
        self.imageName = "hatchedbars.png"

    def constructImage(self):
        bar = Bar()

        bar.xValues = range(5)
        bar.yValues = [2, 4, 6, 8, 10]
        # Valid values include all marker types, /, //, \, \\
        bar.hatch = r"\\"
        bar.color="red"
        bar.edgeColor="black"

        plot = Plot()
        plot.add(bar)
        plot.save(self.imageName)

ImageComparisonTestCase.register(HatchedBarsTest)

if __name__ == "__main__":
    test = HatchedBarsTest("testImageComparison")

    test.constructImage()
Example #14
0
        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)


ImageComparisonTestCase.register(VLineTest)

if __name__ == "__main__":
    test = VLineTest("testImageComparison")

    test.constructImage()
Example #15
0
class FontSizesTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(FontSizesTest, self).__init__(testCaseName)
        self.imageName = "fontsizes.png"

    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)

ImageComparisonTestCase.register(FontSizesTest)

if __name__ == "__main__":
    test = FontSizesTest("testImageComparison")

    test.constructImage()
Example #16
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)

ImageComparisonTestCase.register(VLineTest)

if __name__ == "__main__":
    test = VLineTest("testImageComparison")

    test.constructImage()
Example #17
0
             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)


ImageComparisonTestCase.register(BoxAndWhiskerTest)

if __name__ == "__main__":
    test = BoxAndWhiskerTest("testImageComparison")

    test.constructImage()
Example #18
0
        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)


ImageComparisonTestCase.register(StackedBarTest)

if __name__ == "__main__":
    test = StackedBarTest("testImageComparison")
    test.constructImage()
Example #19
0
        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)

ImageComparisonTestCase.register(ErrorBarsTest)

if __name__ == "__main__":
    test = ErrorBarsTest("testImageComparison")

    test.constructImage()
Example #20
0
            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)


ImageComparisonTestCase.register(StepsTest)

if __name__ == "__main__":
    test = StepsTest("testImageComparison")

    test.constructImage()
Example #21
0
#!/usr/bin/env python

from boomslang import Line, Plot
from ImageComparisonTestCase import ImageComparisonTestCase
import unittest

class SimpleLineTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(SimpleLineTest,self).__init__(testCaseName)
        self.imageName = "simpleline.png"

    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)

ImageComparisonTestCase.register(SimpleLineTest)

if __name__ == "__main__":
    test = SimpleLineTest("testImageComparison")
    test.constructImage()
Example #22
0
        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)


ImageComparisonTestCase.register(LayoutTest)

if __name__ == "__main__":
    test = LayoutTest("testImageComparison")

    test.constructImage()
Example #23
0
        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)

ImageComparisonTestCase.register(TwinXTest)

if __name__ == "__main__":
    test = TwinXTest("testImageComparison")

    test.constructImage()
Example #24
0
class CustomGridTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(CustomGridTest, self).__init__(testCaseName)
        self.imageName = "customgrid.png"

    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)


ImageComparisonTestCase.register(CustomGridTest)

if __name__ == "__main__":
    test = CustomGridTest("testImageComparison")
    test.constructImage()
Example #25
0
        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)


ImageComparisonTestCase.register(ErrorBarsTest)

if __name__ == "__main__":
    test = ErrorBarsTest("testImageComparison")

    test.constructImage()
Example #26
0
    def __init__(self, testCaseName):
        super(LatexTest,self).__init__(testCaseName)
        self.imageName = "latex.png"

    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)

ImageComparisonTestCase.register(LatexTest)

if __name__ == "__main__":
    test = LatexTest("testImageComparison")

    test.constructImage()
Example #27
0
#!/usr/bin/env python

from boomslang import Bar, Plot
import unittest
from ImageComparisonTestCase import ImageComparisonTestCase

class BarTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(BarTest,self).__init__(testCaseName)
        self.imageName = "bar.png"

    def constructImage(self):
        plot = Plot()

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

        plot.add(bar)
        plot.xLabel = "Widget ID"
        plot.yLabel = "# Widgets Sold"

        plot.save(self.imageName)

ImageComparisonTestCase.register(BarTest)

if __name__ == "__main__":
    test = BarTest("testImageComparison")

    test.constructImage()
Example #28
0
                            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)


ImageComparisonTestCase.register(LabelTest)

if __name__ == "__main__":
    test = LabelTest("testImageComparison")

    test.constructImage()
Example #29
0
            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)


ImageComparisonTestCase.register(StepsTest)

if __name__ == "__main__":
    test = StepsTest("testImageComparison")

    test.constructImage()
        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)


ImageComparisonTestCase.register(WeightedLayoutTest)

if __name__ == "__main__":
    test = WeightedLayoutTest("testImageComparison")

    test.constructImage()
Example #31
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)


ImageComparisonTestCase.register(LineStylesTest)

if __name__ == "__main__":
    test = LineStylesTest("testImageComparison")

    test.constructImage()
Example #32
0
#!/usr/bin/env python

from boomslang import Line, Plot
from numpy import arange, pi
from ImageComparisonTestCase import ImageComparisonTestCase
import unittest

class ProjectionTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(ProjectionTest, self).__init__(testCaseName)
        self.imageName = "projection.png"

    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)

ImageComparisonTestCase.register(ProjectionTest)

if __name__ == "__main__":
    test = ProjectionTest("testImageComparison")
    test.constructImage()
Example #33
0
        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)

ImageComparisonTestCase.register(StackedBarTest)

if __name__ == "__main__":
    test = StackedBarTest("testImageComparison")
    test.constructImage()
Example #34
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)

ImageComparisonTestCase.register(StackedLinesTest)

if __name__ == "__main__":
    test = StackedLinesTest("testImageComparison")

    test.constructImage()
Example #35
0
#!/usr/bin/env python

from boomslang import Bar, BrokenAxisPlot
import unittest
from ImageComparisonTestCase import ImageComparisonTestCase

class BrokenAxisTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(BrokenAxisTest,self).__init__(testCaseName)
        self.imageName = "brokenaxis.png"

    def constructImage(self):
        plot = BrokenAxisPlot(break_points=(4,8))

        bar = Bar()
        bar.xValues = range(5)
        bar.yValues = [2, 12, 3, 18.5, 13]

        plot.add(bar)
        plot.setXLabel("Widget ID")
        plot.setYLabel("# Widgets Sold")

        plot.save(self.imageName)

ImageComparisonTestCase.register(BrokenAxisTest)

if __name__ == "__main__":
    test = BrokenAxisTest("constructImage")

    test.constructImage()
Example #36
0
        self.imageName = "split.png"

    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)

ImageComparisonTestCase.register(SplitTest)

if __name__ == "__main__":
    test = SplitTest("testImageComparison")

    test.constructImage()
Example #37
0
        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)


ImageComparisonTestCase.register(LayoutTest)

if __name__ == "__main__":
    test = LayoutTest("testImageComparison")

    test.constructImage()
Example #38
0
                     [
                         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)


ImageComparisonTestCase.register(BoxAndWhiskerTest)

if __name__ == "__main__":
    test = BoxAndWhiskerTest("testImageComparison")

    test.constructImage()
        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)

ImageComparisonTestCase.register(LegendLabelSizesTest)

if __name__ == "__main__":
    test = LegendLabelSizesTest("testImageComparison")

    test.constructImage()
        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)


ImageComparisonTestCase.register(LegendLabelSizesTest)

if __name__ == "__main__":
    test = LegendLabelSizesTest("testImageComparison")

    test.constructImage()
Example #41
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)


ImageComparisonTestCase.register(SplitTest)

if __name__ == "__main__":
    test = SplitTest("testImageComparison")

    test.constructImage()
Example #42
0
import unittest


class GridTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(GridTest, self).__init__(testCaseName)
        self.imageName = "grid.png"

    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 = True

        plot.save(self.imageName)


ImageComparisonTestCase.register(GridTest)

if __name__ == "__main__":
    test = GridTest("testImageComparison")
    test.constructImage()
Example #43
0

class LatexTest(ImageComparisonTestCase, unittest.TestCase):
    def __init__(self, testCaseName):
        super(LatexTest, self).__init__(testCaseName)
        self.imageName = "latex.png"

    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)


ImageComparisonTestCase.register(LatexTest)

if __name__ == "__main__":
    test = LatexTest("testImageComparison")

    test.constructImage()
Example #44
0
    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)

ImageComparisonTestCase.register(ScatterTest)

if __name__ == "__main__":
    test = ScatterTest("testImageComparison")
    test.constructImage()