How do I get vertically stacked plots using JavaPlot?

205 views Asked by At

How can I reproduce these vertically stacked plots, available in gnuplot:

set multiplot
set size 1, 0.5
set origin 0.0,0.5
plot sin(x), log(x)
set origin 0.0,0.0
plot sin(x), log(x), cos(x)
unset multiplot

From JavaPlot (http://javaplot.panayotis.com/)? I have searched for a JavaPlot multiplot example without success. My attempt below:

JavaPlot p = new JavaPlot();
p.set("multiplot", "");
p.set("size", "1, 0.5");
p.set("origin", "0.0,0.5");
p.addPlot("sin(x)");
p.addPlot("log(x)");
p.plot();
// p.newGraph();
p.set("multiplot", "");
p.set("size", "1, 0.5");
p.set("origin", "0.0,0.0");
p.addPlot("sin(x)");
p.addPlot("log(x)");
p.addPlot("cos(x)");
p.plot();

If I run the Java code as above I get a 'top plot' in one window and then a 'bottom plot' in another. If I uncomment p.newGraph(); and comment out p.plot(); I get horizontally stacked plots.

I have also tried using the multiplot layout command like those here http://gnuplot.sourceforge.net/demo/layout.html But not had any luck translating them into a call to JavaPlot.

Reading the JavaPlot documentation I suspect I need to do something with the GridGraphLayout class but can't work out what I'm supposed to do with it.

Thanks,

  • Khalid.
1

There are 1 answers

0
kabdulla On BEST ANSWER

So I wasn't able to get this working within JavaPlot.

In case anyone else reaches this page and wants to use the same work-around I found producing vertically stacked plots, with shared x-axis, quite straightforward in Jfreechart. Some example code here:

CombinedDomainXYPlot not rescaling domain axis