/** * Init a new Plot Pannel with the given data. * * @param title the title of the Plot * @param xLabel the label on the xAxses * @param yLabel the label on the yAxses * @param data the dataset containter * @param type the type of Plot (Runtime, Memory, etc) * @param config the configuration object where the config can be retrieved from * @param tightY * @param tightX */ public BenchmarkPlot( final String title, final String label, final BenchmarkDataset data, final PlotType xAxis, final PlotType yAxis, BenchmarkConfiguration config, boolean tightY, boolean tightX) { super(); synchronized (data.getDatasetLock()) { data.setCurrentPlot(this); this.config = config; this.dataset = data; this.plotTitle = title; this.xAxis = xAxis; this.yAxis = yAxis; /** Process the Styling == make it lines styled */ PlotStyle ps = new PlotStyle(); ps.setStyle(Style.LINES); DataSetPlot dp = new DataSetPlot(this.dataset); dp.setTitle(label); dp.setPlotStyle(ps); // TODO config smooth dp.setSmooth(Smooth.SBEZIER); JavaPlot jp = new JavaPlot(this.config.getGnuPlotLocation()); jp.setTitle(title); jp.getAxis("x").setLabel(xAxis.getLabel()); jp.getAxis("y").setLabel(yAxis.getLabel()); if (tightY) { double minY = dataset.getMinY(); jp.getAxis("y").setBoundaries(minY > 0 ? minY - 1 : minY, dataset.getMaxY() + 1); } if (tightX) { double minX = dataset.getMinX(); jp.getAxis("x").setBoundaries(minX > 0 ? minX - 1 : minX, dataset.getMaxX() + 1); } // Legend location jp.setKey(Key.TOP_LEFT); jp.addPlot(dp); this.setJavaPlot(jp); this.repaint(); } }
/* This demo code uses default terminal. Use it as reference for other javaplot arguments */ private static JavaPlot defaultTerminal(String gnuplotpath) { JavaPlot p = new JavaPlot(gnuplotpath); JavaPlot.getDebugger().setLevel(Debug.VERBOSE); p.setTitle("Default Terminal Title"); p.getAxis("x").setLabel("X axis", "Arial", 20); p.getAxis("y").setLabel("Y axis"); p.getAxis("x").setBoundaries(-30, 20); p.setKey(JavaPlot.Key.TOP_RIGHT); double[][] plot = {{1, 1.1}, {2, 2.2}, {3, 3.3}, {4, 4.3}}; DataSetPlot s = new DataSetPlot(plot); p.addPlot(s); p.addPlot("besj0(x)*0.12e1"); PlotStyle stl = ((AbstractPlot) p.getPlots().get(1)).getPlotStyle(); stl.setStyle(Style.POINTS); stl.setLineType(NamedPlotColor.GOLDENROD); stl.setPointType(5); stl.setPointSize(8); p.addPlot("sin(x)"); p.newGraph(); p.addPlot("sin(x)"); p.newGraph3D(); double[][] plot3d = {{1, 1.1, 3}, {2, 2.2, 3}, {3, 3.3, 3.4}, {4, 4.3, 5}}; p.addPlot(plot3d); p.newGraph3D(); p.addPlot("sin(x)*sin(y)"); p.setMultiTitle("Global test title"); StripeLayout lo = new StripeLayout(); lo.setColumns(9999); p.getPage().setLayout(lo); p.plot(); return p; }