1 package org.jgnuplot;
    2 
    3 /**
    4  * This class provides the samefunctionality as gnuplot param.dem
    5  *
    6  * Show some of the new parametric capabilities.
    7  *
    8  * @author Pander
    9  */
   10 public final class ParamDem {
   11    private ParamDem() {
   12    }
   13 
   14    public static void gnuplot() {
   15       Plot.setGnuplotExecutable("gnuplot");
   16       Plot.setPlotDirectory("/tmp");
   17 
   18       Plot aPlot = new Plot();
   19       aPlot.setParametric();
   20       aPlot.setDummy("t");
   21       aPlot.setAutoscale();
   22       aPlot.setSamples("160");
   23       aPlot.setTitle("");
   24       aPlot.setKey("below box");
   25       aPlot.pushGraph(new Graph("t,sin(t)/t", Axes.NOT_SPECIFIED,
   26             "t, sin(t)/t or sin(x)/x"));
   27       aPlot.setOutput(Terminal.PNG, "test/out/param-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.pushGraph(new Graph("sin(t),t"));
   38       aPlot.setOutput(Terminal.PNG, "test/out/param-02.png");
   39       try {
   40          aPlot.plot();
   41       }
   42       catch (Exception e) {
   43          System.err.println(e);
   44          System.exit(1);
   45       }
   46 
   47       aPlot.clear();
   48       aPlot.pushGraph(new Graph("sin(t),cos(t)"));
   49       aPlot.setOutput(Terminal.PNG, "test/out/param-03.png");
   50       try {
   51          aPlot.plot();
   52       }
   53       catch (Exception e) {
   54          System.err.println(e);
   55          System.exit(1);
   56       }
   57 
   58       aPlot.clear();
   59       aPlot.setXRange("-3", "3");
   60       aPlot.setYRange("-3", "3");
   61       aPlot.setTitle("Parametric Conic Sections");
   62       aPlot.pushGraph(new Graph("-t,t"));
   63       aPlot.pushGraph(new Graph("cos(t),cos(2*t)"));
   64       aPlot.pushGraph(new Graph("2*cos(t),sin(t)"));
   65       aPlot.pushGraph(new Graph("-cosh(t),sinh(t)"));
   66       aPlot.setOutput(Terminal.PNG, "test/out/param-04.png");
   67       try {
   68          aPlot.plot();
   69       }
   70       catch (Exception e) {
   71          System.err.println(e);
   72          System.exit(1);
   73       }
   74 
   75       aPlot.clear();
   76       aPlot.setXRange("-5", "5");
   77       aPlot.setYRange("-5", "5");
   78       aPlot.pushGraph(new Graph("tan(t),t"));
   79       aPlot.pushGraph(new Graph("t,tan(t)"));
   80       aPlot.setOutput(Terminal.PNG, "test/out/param-05.png");
   81       try {
   82          aPlot.plot();
   83       }
   84       catch (Exception e) {
   85          System.err.println(e);
   86          System.exit(1);
   87       }
   88    }
   89 }