0

I was trying to monitor the change of some parameters using JavaPlot.

Is there a way to simply update the plot of data in the original plot?

1 Answers1

0

I think you cannot do this with JavaPlot.

JavaPlot doesn't have a single gnuplot instance running in the background which it pipes commands to. For every plot it creates a new temporary file which is then called with gnuplot. That means, that after using p.plot() you don't have any access to the gnuplot window containing the plot.

Consider the following short example:

import com.panayotis.gnuplot.JavaPlot;
import com.panayotis.gnuplot.utils.Debug;

public class test {
    public static void main(String[] args) {
        JavaPlot p = new JavaPlot();
    p.getDebugger().setLevel(Debug.INFO);
        p.addPlot("sin(x)");
        p.plot();
    p.plot();
    }
}

That opens two windows and prints the messages:

** Start of plot commands **
plot sin(x) title 'sin(x)'
quit
** End of plot commands **
exec(/usr/bin/gnuplot /tmp/gnuplot_5778913101279507298.dat -persist )
** Start of plot commands **
plot sin(x) title 'sin(x)'
quit
** End of plot commands **
exec(/usr/bin/gnuplot /tmp/gnuplot_4590356376057662873.dat -persist )

You see that two different temporary files are created.

Christoph
  • 47,569
  • 8
  • 87
  • 187
  • Thank you very much..... I guess this means I need to write the graphic interface by myself... =( sigh – Pierre Lorentz May 13 '14 at 19:25
  • Depending on your other requirements it might be enough to extend the `GNUPlotExec` class to add an finite or infinite loop at the end of the script file: `iter = 0; while (iter < 100) { refresh; iter = iter+1; pause 5; }`. – Christoph May 13 '14 at 19:33