def _createChart(self): # create the plot rtimeDataset = self.dataSets[0] rtimeRenderer = StackedXYAreaRenderer2() rtimeRangeAxis = NumberAxis(self.getYAxisLabel()) rtimeRangeAxis.setAutoRangeIncludesZero(False) rtimeDomainAxis = NumberAxis(self.getXAxisLabel()) #rtimePlot = XYPlot(rtimeDataset, None, rtimeRangeAxis, rtimeRenderer) rtimePlot = XYPlot(rtimeDataset, rtimeDomainAxis, rtimeRangeAxis, rtimeRenderer) rtimePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT) # response time rtimeRenderer.setSeriesPaint(0, COLOR_RTIME_RESOLVE) rtimeRenderer.setSeriesPaint(1, COLOR_RTIME_CONNECT) rtimeRenderer.setSeriesPaint(2, COLOR_RTIME_FIRSTBYTE) rtimeRenderer.setSeriesPaint(3, COLOR_RTIME_FINAL) #rtimeRenderer.setBaseShapesVisible(False) #rtimePlot.setRenderer(0, rtimeRenderer) rtimePlot.setRenderer(rtimeRenderer) # create a new chart containing the plot... self.chart = JFreeChart(self.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, rtimePlot, True)
def scatterplot(data, name="", xlabel="", ylabel="", size= 3): """ Creates a scatter plot from x,y data. *data* is a list of (x,y) tuples. """ xAxis = NumberAxis(xlabel) xAxis.setAutoRangeIncludesZero(False) yAxis = NumberAxis(ylabel) yAxis.setAutoRangeIncludesZero(False) series = XYSeries("Values"); for (i,j) in data: series.add(i, j) dataset = XYSeriesCollection() dataset.addSeries(series); chart = ChartFactory.createScatterPlot(name, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, True, True, False) plot = chart.getPlot() plot.getRenderer().setSeriesShape(0, ShapeUtilities.createRegularCross(size,size)); return Chart(chart)
def _createChart(self): # create subplot 1... tpsDataset = self.dataSets[0] passPerSecRenderer = StandardXYItemRenderer() tpsRangeAxis = NumberAxis("Transactions per second") tpsSubplot = XYPlot(tpsDataset, None, tpsRangeAxis, passPerSecRenderer); tpsSubplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT) # create subplot 2... rtimeDataset = self.dataSets[1] rtimeRenderer = StandardXYItemRenderer() rtimeRangeAxis = NumberAxis("Response Time") rtimeRangeAxis.setAutoRangeIncludesZero(False) rtimeSubplot = XYPlot(rtimeDataset, None, rtimeRangeAxis, rtimeRenderer) rtimeSubplot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT) # parent plot... plot = CombinedDomainXYPlot(NumberAxis(self.getXAxisLabel())) plot.setGap(10.0) # passed per sec # RGB for dark green passPerSecRenderer.setSeriesPaint(0, COLOR_TXSEC_PASS) passPerSecRenderer.setSeriesPaint(1, COLOR_TXSEC_FAIL) passPerSecRenderer.setBaseShapesVisible(False) # response time rtimeRenderer.setSeriesPaint(0, COLOR_RTIME) rtimeRenderer.setBaseShapesVisible(False) # failed per sec failPerSecRenderer = StandardXYItemRenderer() failPerSecRenderer.setSeriesPaint(0, javaColor.red) failPerSecRenderer.setBaseShapesVisible(False) tpsSubplot.setRenderer(0, passPerSecRenderer) tpsSubplot.setRenderer(1, failPerSecRenderer) rtimeSubplot.setRenderer(0, rtimeRenderer) # add the subplots. TPS plot gets more weight, # making it proportionally larger. plot.add(tpsSubplot, CONFIG.tpsWeight) plot.add(rtimeSubplot, CONFIG.responseTimeWeight) plot.setOrientation(PlotOrientation.VERTICAL) # create a new chart containing the overlaid plot... self.chart = JFreeChart(self.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, True)
def regression(data, regtype=0): xAxis = NumberAxis("x") xAxis.setAutoRangeIncludesZero(False) yAxis = NumberAxis("y") yAxis.setAutoRangeIncludesZero(False) series = XYSeries("values") xmax = xmin = None for (x, y) in data: series.add(x, y) if xmax is None: xmax = xmin = x else: xmax = max(xmax, x) xmin = min(xmin, x) dataset = XYSeriesCollection() dataset.addSeries(series) renderer1 = XYDotRenderer() plot = XYPlot(dataset, xAxis, yAxis, renderer1) if regtype == 1: coefficients = Regression.getPowerRegression(dataset, 0) curve = PowerFunction2D(coefficients[0], coefficients[1]) regdesc = "Power Regression" else: coefficients = Regression.getOLSRegression(dataset, 0) curve = LineFunction2D(coefficients[0], coefficients[1]) regdesc = "Linear Regression" regressionData = DatasetUtilities.sampleFunction2D( curve, xmin, xmax, 100, "Fitted Regression Line") plot.setDataset(1, regressionData) renderer2 = XYLineAndShapeRenderer(True, False) renderer2.setSeriesPaint(0, Color.blue) plot.setRenderer(1, renderer2) jfchart = JFreeChart(regdesc, JFreeChart.DEFAULT_TITLE_FONT, plot, True) chart = Chart(jfchart) chart.coeffs = coefficients return chart
def regression(data, regtype=0): xAxis = NumberAxis("x") xAxis.setAutoRangeIncludesZero(False) yAxis = NumberAxis("y") yAxis.setAutoRangeIncludesZero(False) series = XYSeries("values"); xmax = xmin = None for (x,y) in data: series.add(x, y); if xmax is None: xmax = xmin = x else: xmax = max(xmax, x) xmin = min(xmin, x) dataset = XYSeriesCollection() dataset.addSeries(series); renderer1 = XYDotRenderer() plot = XYPlot(dataset, xAxis, yAxis, renderer1) if regtype == 1: coefficients = Regression.getPowerRegression(dataset, 0) curve = PowerFunction2D(coefficients[0], coefficients[1]) regdesc = "Power Regression" else: coefficients = Regression.getOLSRegression(dataset, 0) curve = LineFunction2D(coefficients[0], coefficients[1]) regdesc = "Linear Regression" regressionData = DatasetUtilities.sampleFunction2D(curve, xmin, xmax, 100, "Fitted Regression Line") plot.setDataset(1, regressionData) renderer2 = XYLineAndShapeRenderer(True, False) renderer2.setSeriesPaint(0, Color.blue) plot.setRenderer(1, renderer2) jfchart = JFreeChart(regdesc, JFreeChart.DEFAULT_TITLE_FONT, plot, True); chart = Chart(jfchart) chart.coeffs = coefficients return chart