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): 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): 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 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
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)
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): 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)
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)
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): 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)
#!/usr/bin/env python from boomslang import Bar, Plot plot = Plot() bar = Bar() bar.xValues = range(5) bar.yValues = [2, 8, 4, 6, 5] plot.add(bar) plot.setXLabel("Widget ID") plot.setYLabel("# Widgets Sold") plot.save("bar.png")
y = (float(row1[' OptWpS']) + float(row2[' OptWpS']) + float(row3[' OptWpS'])) / 3.0 dataY.append(y) y = (float(row1[' Opt2WpS']) + float(row2[' Opt2WpS']) + float(row3[' Opt2WpS'])) / 3.0 dataY.append(y) except: pass bars = [] labels = ['Reference', 'OMP - For', 'OMP - Tasks', 'Comp-Opt', 'Manual-Opt'] colors = ['yellow', 'red', 'orange', 'blue', 'green'] index = 0 for y in dataY: bar = Bar() bar.xValues = [index] bar.yValues = [y] bar.color = colors[index] bar.label = labels[index] index += 1 bars.append(bar) plot = Plot() for bar in bars: plot.add(bar) plot.setXLabel("Versions") plot.setYLabel("WpS") plot.hasLegend() plot.save("seq.png")
try: while True: row1 = data.next() row2 = data.next() row3 = data.next() x = int(row1[" K"]) / 20 y = (float(row1[" PforMSWpS"]) + float(row2[" PforMSWpS"]) + float(row3[" PforMSWpS"])) / 3.0 threadsData[row1[" THREADS"].strip()][0].append(x) threadsData[row1[" THREADS"].strip()][1].append(y) except: pass bar1 = Bar() bar1.xValues = threadsData["1"][0] bar1.yValues = threadsData["1"][1] bar1.color = "red" bar1.label = "1 Thread" bar2 = Bar() bar2.xValues = threadsData["2"][0] bar2.yValues = threadsData["2"][1] bar2.color = "blue" bar2.label = "2 Threads" bar3 = Bar() bar3.xValues = threadsData["3"][0] bar3.yValues = threadsData["3"][1] bar3.color = "green" bar3.label = "3 Threads"
from boomslang import Bar, Line, Scatter, Plot, PlotLayout 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")
#!/usr/bin/env python from boomslang import StackedBars, Bar, Plot 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)