Example of JavaPlot usage

Here is a quick and easy example to see JavaPlot in action.

Create a file (e.g. test.java) with this code:

import com.panayotis.gnuplot.JavaPlot;

 

public class test {

    public static void main(String[] args) {

        JavaPlot p = new JavaPlot();

        p.addPlot("sin(x)");

        p.plot();

    }

}

Compile this file as follows:

javac -cp PATH_TO_JAVAPLOT/dist/JavaPlot.jar test.java

and run it:

java -cp PATH_TO_JAVAPLOT/dist/JavaPlot.jar:. test

This demo, and a couple more, can be found in demo/src/demo.java file in the JavaPlot distribution. To run this pre-compiled demo, type:

cd PATH_TO_JAVAPLOT/demo/dist ; java -jar demo.jar

Have fun!