1 package org.jgnuplot; 2 3 /** 4 * This class provides the samefunctionality as gnuplot using.dem 5 * 6 * Requires data file "using.dat" from this directory, so change current working 7 * directory to this directory before running. 8 * 9 * @author Pander 10 */ 11 public final class UsingDem { 12 private UsingDem() { 13 } 14 15 public static void gnuplot() { 16 Plot.setGnuplotExecutable("gnuplot"); 17 Plot.setPlotDirectory("/tmp"); 18 19 Plot aPlot = new Plot(); 20 aPlot.setTitle("Convex November 1-7 1989 Circadian"); 21 aPlot.setKey("left box"); 22 aPlot.setXRange("-1", "24"); 23 aPlot.pushGraph(new Graph("using.dat", "2:4", Axes.NOT_SPECIFIED, 24 "Logged in", Style.IMPULSES)); 25 aPlot.pushGraph(new Graph("using.dat", "2:4", Axes.NOT_SPECIFIED, 26 "Logged in", Style.POINTS)); 27 aPlot.setOutput(Terminal.PNG, "test/out/using-01.png"); 28 try { 29 aPlot.plot(); 30 } 31 catch (Exception e) { 32 System.err.println(e); 33 System.exit(1); 34 } 35 36 aPlot.clear(); 37 aPlot.setXRange("1", "8"); 38 aPlot.setTitle("Convex November 1-7 1989"); 39 aPlot.setKey("below"); 40 aPlot.addExtra("set label \"(Weekend)\" at 5,25 center"); 41 aPlot.pushGraph(new Graph("using.dat", "3:4", Axes.NOT_SPECIFIED, 42 "Logged in", Style.IMPULSES)); 43 aPlot.pushGraph(new Graph("using.dat", "3:5", Axes.NOT_SPECIFIED, 44 "Load average", Style.POINTS)); 45 aPlot.pushGraph(new Graph("using.dat", "3:6", Axes.NOT_SPECIFIED, 46 "%CPU used", Style.LINES)); 47 aPlot.setOutput(Terminal.PNG, "test/out/using-02.png"); 48 try { 49 aPlot.plot(); 50 } 51 catch (Exception e) { 52 System.err.println(e); 53 System.exit(1); 54 } 55 } 56 }