I'm desperately trying to get Java and gnuplot to play nice. I've started using JavaPlot
and have added the jar to the classpath (using Eclipse).
I've also downloaded gnuplot and have placed it in a safe place.
First question, all examples given by JavaPlot
are assuming you have put gnuplot in the right place, where this is I have no idea. Therefore their example of:
import com.panayotis.gnuplot.JavaPlot;
public class test {
public static void main(String[] args) {
JavaPlot p = new JavaPlot();
p.addPlot("sin(x)");
p.plot();
}
}
Will only work if gnuplot is added to the classpath, any ideas on where that might be and how?
Not to worry though, as you can define the location of gnuplot in the constructor of JavaPlot, like so:
import com.panayotis.gnuplot.JavaPlot;
public class test {
public static void main(String[] args) {
JavaPlot p = new JavaPlot("D:/Eclipse/gnuplot/binary/pgnuplot.exe");
p.addPlot("sin(x)");
p.plot();
}
}
This does something, if you're quick you can see a graph appear (correctly, can see the sine wave) and then immediately disappear. I've read online that in the actual gnuplot application this is common when using Windows and that a '-persist' must be added after the plot. Fortunately JavaPlot
also has a function that does that:
p.setPersist(true);
But in my case it does nothing. So second question, anyone used gnuplot, JavaPlot
, and Windows 7 64bit before and know how to do this? From my Googling I understand pgnuplot is the correct .exe to run?
What am I missing? What am I doing wrong?