Exemple #1
0
    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)
Exemple #2
0
    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)
Exemple #3
0
def getBinBars(rows,
               binKey,
               quantityKey,
               xLabelFormattingFunction,
               xLabel,
               yLabel,
               xLabelRotation=0):
    bins = []
    countsPerBin = []

    for row in rows:
        bins.append(int(row[binKey]))
        countsPerBin.append(int(row[quantityKey]))

    bar = Bar()
    bar.xValues = bins
    bar.yValues = countsPerBin

    if xLabelFormattingFunction is not None:
        bar.xTickLabelPoints = range(len(bins))
        bar.xTickLabels = map(xLabelFormattingFunction, bar.xTickLabelPoints)

    if xLabelRotation > 0:
        bar.setXTickLabelProperties(rotation=str(xLabelRotation))

    barPlot = Plot()
    barPlot.add(bar)
    barPlot.setXLabel(xLabel)
    barPlot.setYLabel(yLabel)
    #    barPlot.setXLimits(0, None)
    return barPlot
Exemple #4
0
    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)
    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)
    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 #7
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)
    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 plot_timeline_for_phase(log_directory, job, phase, phase_data):
    min_timestamp = phase_data["min_timestamp"]
    max_timestamp = phase_data["max_timestamp"]

    description = Description(os.path.join(log_directory, job, "description"))
    stage_ordering = description.getStageOrdering(phase)

    duration_lists = {}

    for stage in stage_ordering:
        duration_lists[stage] = []

    for key in phase_data:
        if key in ["min_timestamp", "max_timestamp"]:
            continue

        hostname, stage, worker_id = key

        worker_duration_info = Duration(
            hostname.split('.')[0], stage, worker_id,
            (phase_data[key][0] - min_timestamp) / 1000000.0,
            (phase_data[key][1] - min_timestamp) / 1000000.0)

        duration_lists[stage].append(worker_duration_info)

    def sort_function(x):
        return (x.hostname, x.worker_id, x.start_time, x.stop_time)

    layout = PlotLayout()

    for stage in stage_ordering:
        duration_list = duration_lists[stage]

        duration_list.sort(key=sort_function)

        bars = {}

        # Set up a "padding" bar that will appear to move bars up so that they
        # start when the worker starts
        start_bar = Bar()
        start_bar.linewidth = 0
        start_bar.color = "white"

        for i, duration in enumerate(duration_list):
            if duration.hostname not in bars:
                bars[duration.hostname] = Bar()

            bars[duration.hostname].yValues.append(duration.stop_time -
                                                   duration.start_time)
            start_bar.yValues.append(duration.start_time)

        # Make sure that all bars have the same number of y-axis values,
        # give them x-axis values and set their colors

        start_bar.xValues = range(len(start_bar.yValues))
        start_bar.xTickLabelProperties = {"rotation": 90}

        bar_colors = [
            "red", "blue", "green", "orange", "gray", "pink", "purple", "black"
        ]

        offset = 0

        for i, (hostname, bar) in enumerate(bars.items()):
            # Pad y axis with zeroes so that bars can be laid out next to
            # each other with a StackedBars
            num_y_values = len(bar.yValues)

            bar.yValues = (([0] * offset) + bar.yValues +
                           ([0] * (len(duration_list) -
                                   (num_y_values + offset))))

            # Put the label for this hostname roughly in the middle of its bar
            # cluster
            start_bar.xTickLabels.append(hostname)
            # Subtracting 0.5 to account for half the width of the bar
            start_bar.xTickLabelPoints.append(offset + (num_y_values / 2.0) -
                                              0.5)

            offset += num_y_values

            bar.xValues = range(len(bar.yValues))
            bar.color = bar_colors[i % len(bar_colors)]
            bar.label = hostname

        stacked_bars = StackedBars()
        stacked_bars.add(start_bar)

        for hostname in sorted(bars.keys()):
            stacked_bars.add(bars[hostname])

        plot = Plot()
        plot.setYLimits(0,
                        ((max_timestamp - min_timestamp) / 1000000.0) * 1.05)
        plot.setXLabel("Worker")
        plot.setYLabel("Time (s)")
        plot.setTitle(stage)

        plot.add(stacked_bars)
        layout.addPlot(plot)

    return layout